SharePoint Powershell for Solution Deployment (WSP)
So we have covered a couple of areas with PowerShell but on of the most used, especially for those of use that like to play around with SharePoint, is the addition of solutions and features to our farms.
Now that we have PowerShell available in SharePoint 2010 you should really be using this to add your solutions, even though you can still do this with stsadm (but come on who wants to)
MOSS Solution Commands
In the 2007 days there were essentially 5 different commands used for dealing with solutions:
We added solutions using the addsolution command to the Farm:
stsadm –o addsolution –filename "C:\Deployment\MySharePointSolutionPackage.wsp"
To deploy the solution we used the deploysolution command:
stsadm –o deploysolution –name MySharePointSolutionPackage.wsp –url http://webapplication –allowgacdeployment –immediate
To upgrade a solution we used the upgradesolution command:
stsadm –o upgradesolution –name MySharePointSolutionPackage.wsp –filename "C:\Deployment\MySharePointSolutionPackage.wsp" –immediate
To retract and remove a solution we used the retractsolution and removesolution commands respectively:
stsadm –o retractsolution –name MySharePointSolutionPackage.wsp –url http://webapplication –immediate stsadm –o deletesolution –name MySharePointSolutionPackage.wsp
Powershell Solution Cmdlets
Adding
To add a solution to the Farm solution store use the Add-SPSolution cmdlet:
Add-SPSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp"
To add a Sandboxed solution use the Add-SPUserSolution cmdlet:
Add-SPUserSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp" –Site http://webapplication/sitecollection
Installing
To install ( commonly known as deploy) a Farm Solution we use the Install-SPSolution cmdlet:
Install-SPSolution –Identity MySharePointSolutionPackage.wsp –WebApplication http://webapplication –GACDeployment
To install ( commonly known as deploy) a Sandboxed Solution we use the Install-SPUserSolution cmdlet:
Install-SPUserSolution –Identity MySharePointSolutionPackage.wsp –Site http://webapplication/sitecollection
Updating
To update (know as upgrade in stsadm) a Farm solution use the Update-SPSolution cmdlet:
Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath “C:\Deployment\MySharePointSolutionPackage.wsp” –GacDeployment
To update (know as upgrade in stsadm) a Sandbox solution use the Update-SPUserSolution cmdlet:
Update-SPUserSolution –Identity MySharePointSolution.wsp –Site http://webapplication/site –ToSolution MySharePointSolutionPackage.wsp
Removing
To uninstall and remove FARM level solutions use the Uninstall-SPSolution and Remove-SPSolution cmdlets:
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://webapplication Remove-SPSolution –Identity MySharePointSolution.wsp
To uninstall and remove Sandbox solutions use the Uninstall-SPSolution and Remove-SPSolution cmdlets:
Uninstall-SPUserSolution –Identity MySharePointSolution.wsp –Site http://webapplication/sitecollection Remove-SPUserSolution –Identity MySharePointSolution.wsp –Site http://webapplication/sitecollection
To get a list of all of the powershell cmdlets that deal with solutions use:
Get-Command –noun *SPSolution*
To run all of the Administrative jobs that are queued:
Start-SPAdminJob
So that’s it, next time let’s looks at some basic feature powershell cmdlets as well





[...] STSADM vs POWERSHELL commands re: solutions in SharePoint 2010 – http://www.sharepointanalysthq.com/2010/08/sharepoint-powershell-for-solution-deployment-wsp/ [...]
[...] http://www.sharepointanalysthq.com/2010/08/sharepoint-powershell-for-solution-deployment-wsp/ [...]