Monday, June 20, 2011

Few important power shell commands

Before trying any of the following commands in powershell make sure that service SharePoint 2010 Administrationis started. if it is not started then start it.

Go to Start -> All Programmers -> Microsoft SharePoint 2010 Products -> SharePoint 2010 Management Shell


To install a solution we use the Add-SPSolution command. If you are using a Sandboxed solution you would use Add-SPUserSolution instead. But for Sandbox solution I would prefer adding the wsp file using GUI in Central Admin.

PS C:\Users\user1> Add-SPSolution C:\mySolution.wsp

Now to deploy the solution to your Sharepoint site we shall use Install-SPSolution


PS C:\Users\user1> Install-SPSolution -Identity mySolution.wsp -WebApplication https://mySiteURL –GACDeployment

To upgrade solution use Update-SPSolution

PS C:\Users\user1>Update-SPSolution –Identity mySolution.wsp –LiteralPath C:\mySolution.wsp –GACDeployment

To retract a solution we use the Uninstall-SPSolution

PS C:\Users\user1>Uninstall-SPSolution –Identity mySolution.wsp –WebApplication https://mySiteURL

And to remove it from solution store use Remove-SPSolution

PS C:\Users\user1>Remove-SPSolution –Identity mySolution.wsp

Few little troubleshooting.
1. You may sometime see the following error when trying Install-SPSolution

Install-SPSolution : This solution contains no resources scoped for a Web appli
cation and cannot be deployed to a particular Web application.

Then try this instead
PS C:\Users\user1> Install-SPSolution -Identity mySolution.wsp –GACDeployment

2. If any of your deploy command fails you will not be able to deploy it again. If you try again you will see the following error

A deployment or retraction is already under way for the so
lution "yourSolution", and only one deployment or retraction at a time is supported.....

To handle this issue open central admin. Go to Monitoring->Review Timer Job Definitions
Then find the job which has you solution name in title. Delete it.

3. You may see the following error if SharePoint 2010 Administration service is not started.

Install-SPSolution: Admin SVC must be running in order to create deployment timer job

So all you need to do is to go to the Services section in Control Panel\System and Security\Administrative Tools and look for the service called SharePoint 2010 Administration, it was on manual start up, changed it to automatic and started it and gotten rid of this error.

No comments: