How to deploy a WSP using PowerShell in SharePoint 2010


In this article we will be seeing how to deploy a wsp file using Power Shell in SharePoint 2010 and how to install, activate, deactivate and uninstall the features.

Steps Involved:

Go to All Programs => Microsoft SharePoint 2010 Products =>SharePoint 2010 Management Shell =>Run as administrator.

1.gif 

Adding the solution:

Add-SPSolution "C:\Users\sjfa\Desktop\WSPTest\WSPTest\bin\Debug\WSPTest.wsp"

2.gif 
 
You have successfully added the solution; it gives the Name, Solution Id and Deployed status of the wsp file.

The Deployed status is false, we have just added the wsp file but not deployed.

Deploying the solution:

Install-SPSolution -identity "WSPTest.wsp" –GACDeployment

3.gif
 
Sometimes when you install the solution you may get the following error.

4.gif
 
How to resolve this:
  • Go to Run.
  • Type services.msc.
  • Services window will open.
  • Start SharePoint 2010 Administration service.
5.gif

Retracting the Solution:

Uninstall-SPSolution -identity "WSPTest.wsp"

Removing the solution:

Remove-SPSolution -identity "WSPTest.wsp"

Installing the feature:

Install-SPFeature "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\WSPTest_WSPContentTypeFeature"

6.gif
 
Where "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\WSPTest_WSPContentTypeFeature" is the Folder Name Path.

Activating the feature:

Enable-SPFeature -Identity "GUID" -Url "http://servername:2010"

7.gif 
 
Deactivating the feature:

Disable-SPFeature -Identity "GUID" -Url "http://servername:2010"

8.gif
 
Uninstalling the feature:

Uninstall-SPFeature -Identity "GUID"

Up Next
    Ebook Download
    View all
    Learn
    View all