First of all, we need to clarify that PowerShell command is only available for SharePoint since SharePoint 2010, we can only use Stsadm for previous versions of SharePoint.
If you are using a normal PowerShell console instead of “SharePoint Management Shell”, you may need to register snapin of SharePoint, there are two ways to register:
Option 1:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Config\PowerShell\Registration\SharePoint.ps1
Note: 14 is SharePoint version number
* 14 – SharePoint 2010
* 15 – SharePoint 2013
Option 2:
Add-PSSnapin Microsoft.SharePoint.PowerShell
Basic SharePoint deployment scripts comparison
- Add solution
- Stsadm
stsadm –o addsolution –filename "C:\WSPs\MySharePointSolution.wsp"
- PowerShell
Add-SPSolution "C:\WSPs\MySharePointSolution.wsp"
- Deploy solution
- Stsadm
stsadm –o deploysolution –name MySharePointSolution.wsp –url http://spwebapp –allowgacdeployment –immediate
- PowerShell
Install-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://spwebapp –GACDeployment
Note: Use Install-SPUserSolution for sandboxsolution
- Upgrade solution (only use this command when there is no new features)
- Stsadm
stsadm –o upgradesolution –name MySharePointSolution.wsp –filename "C:\WSPs\MySharePointSolution.wsp" –immediate
- PowerShell
Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath "C:\WSPs\MySharePointSolution.wsp" –GacDeployment
- Retract solution
- Stsadm
stsadm –o retractsolution –name MySharePointSolution.wsp –url http://spwebapp –immediatestsadm –o
- PowerShell
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://spwebapp Add-SPSolution "C:\WSPs\MySharePointSolution.wsp"
- Remove solution
- Stsadm
stsadm –o deletesolution –name MySharePointSolution.wsp
- PowerShell
Remove-SPSolution –Identity MySharePointSolution.wsp
- Activate feature
- Stsadm
stsadm –o activatefeature –name MyFeatureName –url http://spwebapp
- PowerShell
Enable-SPFeature –Identity MyFeatureNameOrGuid –url http://spwebapp
- Deactivate feature
- Stsadm
stsadm –o deactivatefeature –name MyFeatureName –url http://spwebapp
- PowerShell
Disable-SPFeature –Identity MyFeatureNameOrGuid –url http://spwebapp
Read more at Microsoft web site http://technet.microsoft.com/en-us/library/ee906565(v=office.15).aspx
Reference: http://patrickboom.wordpress.com/2010/05/31/using-powershell-to-deploy-sharepoint-solutions-wsp-2/