How to Deploy sharepoint 2010 solutions using Powershell

Here are the commands for your Powershell script to remove and re-add a solution package  in SharePoint 2010

To Open the Windows PowerShell Session :

1. On the Start menu, click All Programs.

2. Click Microsoft SharePoint 2010 Products.

3. Click SharePoint 2010 Management Shell

Note : You should have SharePoint_Shell_Access role on the configuration database and you should be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint Server 2010 is installed.

Now, type in the following comamnds  ( Note that the first two are needed only if the Solution already exists and you need to retract it before adding a new one.

Uninstall-SPSolution -identity {name of wsp file} -allwebapplications

remove-spsolution -identity {name of wsp file} -force

add-spsolution -literalpath C:\{FULL file system location\name of wsp file}

install-spsolution -identity {name of wsp file} -webapplication http://{URL of SharePoint site to deploy to} -GACDeployment -force

For more commands see SharePoint 2010 Windows PowerShell Commands - I