Tuesday, June 19, 2012

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:
1stsadm –o addsolution –filename "C:\Deployment\MySharePointSolutionPackage.wsp"
To deploy the solution we used the deploysolution command:
1stsadm –o deploysolution –name MySharePointSolutionPackage.wsp –urlhttp://webapplication –allowgacdeployment –immediate
To upgrade a solution we used the upgradesolution command:
1stsadm –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:
1stsadm –o retractsolution –name MySharePointSolutionPackage.wsp –urlhttp://webapplication –immediate
2stsadm –o deletesolution –name MySharePointSolutionPackage.wsp

Powershell Solution Cmdlets

Adding

To add a solution to the Farm solution store use the Add-SPSolution cmdlet:
1Add-SPSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp"
To add a Sandboxed solution  use the Add-SPUserSolution cmdlet:
1Add-SPUserSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp" –Sitehttp://webapplication/sitecollection

Installing

To install ( commonly known as deploy)  a Farm Solution we use the Install-SPSolution cmdlet:
1Install-SPSolution –Identity MySharePointSolutionPackage.wsp –WebApplication http://webapplication –GACDeployment
To install ( commonly known as deploy)  a Sandboxed Solution we use the Install-SPUserSolutioncmdlet:
1Install-SPUserSolution –Identity MySharePointSolutionPackage.wsp –Sitehttp://webapplication/sitecollection

Updating

To update (know as upgrade in stsadm) a Farm solution use the Update-SPSolution cmdlet:
1Update-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:
1Update-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/site –ToSolution MySharePointSolutionPackage.wsp

Removing

To uninstall and remove FARM level solutions use the Uninstall-SPSolution and Remove-SPSolutioncmdlets:
1Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplicationhttp://webapplication
2Remove-SPSolution –Identity MySharePointSolution.wsp
To uninstall and remove Sandbox solutions use the Uninstall-SPSolution and Remove-SPSolutioncmdlets:
1Uninstall-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/sitecollection
2Remove-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/sitecollection
To get a list of all of the powershell cmdlets that deal with solutions use:
1Get-Command –noun *SPSolution*
To run all of the Administrative jobs that are queued:
1Start-SPAdminJob

No comments:

Post a Comment