Pages

Subscribe:

Thursday, March 29, 2012

PowerShell to deploy SharePoint Solutions


Working with Solutions

The following stsadm command could be used to add a SharePoint solution to SharePoint:
stsadm –o addsolution –filename “E:\WSP\CreateProject.wsp
We used the following command to deploy the solution once installed to a specific web application:
stsadm –o deploysolution –name CreateProject.wsp –url http://sp2010 –allowgacdeployment –immediate
If we would upgrade an existing solution, we would use the following:
stsadm –o upgradesolution –name CreateProject.wsp  –filename “E:\WSP\CreateProject.wsp” -immediate
And finally, we used the following commands to retract and delete a specific solution from the web application:
stsadm –o retractsolution –name CreateProject.wsp  –url http://sp2010 –immediate
stsadm –o deletesolution –name 
CreateProject.wsp 
Now, let us see how we could do above operations with PowerShell. For this, we use the following PowerShell commands:
Add-SPSolution E:\WSP\CreateProject.wsp
Install-SPSolution –Identity 
CreateProject.wsp –WebApplication http://sp2010 –GACDeployment
If you would like to add the solution as sandboxed, you would use the Install-SPUserSolution command instead. To upgrade a solution, we specify which solution is to be updated and with which new solution file:
Update-SPSolution –Identity CreateProject.wsp –LiteralPath “E:\WSP\CreateProject.wsp” –GacDeployment
To retract and remove a solution, we use the following commands:
Uninstall-SPSolution –Identity CreateProject.wsp –WebApplication http://sp2010
Remove-SPSolution–Identity
 CreateProject.wsp

Working with features

Similarly, commands exist for working with features. The stsadm equivalents:
stsadm –o activatefeature –name FeatureName –url http://sp2010
stsadm –o deactivatefeature –name 
FeatureName –url http://sp2010
Needless to say, there are easy equivalents in PowerShell:
Enable-SPFeature –Identity FeatureNameOrGuid –url http://sp2010
Disable-SPFeature –Identity 
FeatureNameOrGuid –url http://sp2010

No comments:

Post a Comment