First of all, we need to clarify that PowerShell command is only available for SharePoint since SharePoint 2010, we can only use Stsadm for previous versions of SharePoint.

If you are using a normal PowerShell console instead of “SharePoint Management Shell”, you may need to register snapin of SharePoint, there are two ways to register:

Option 1:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Config\PowerShell\Registration\SharePoint.ps1

Note: 14 is SharePoint version number
* 14 – SharePoint 2010
* 15 – SharePoint 2013

Option 2:

Add-PSSnapin Microsoft.SharePoint.PowerShell

Basic SharePoint deployment scripts comparison

  1. Add solution
    • Stsadm
    stsadm –o addsolution –filename "C:\WSPs\MySharePointSolution.wsp"
    
    • PowerShell
    Add-SPSolution "C:\WSPs\MySharePointSolution.wsp"
    
  2. Deploy solution
    • Stsadm
    stsadm –o deploysolution –name MySharePointSolution.wsp –url http://spwebapp –allowgacdeployment –immediate
    
    • PowerShell
    Install-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://spwebapp –GACDeployment
    

    Note: Use Install-SPUserSolution for sandboxsolution

  3. Upgrade solution (only use this command when there is no new features)
    • Stsadm
    stsadm –o upgradesolution –name MySharePointSolution.wsp –filename "C:\WSPs\MySharePointSolution.wsp" –immediate
    
    • PowerShell
    Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath "C:\WSPs\MySharePointSolution.wsp" –GacDeployment
    
  4. Retract solution
    • Stsadm
    stsadm –o retractsolution –name MySharePointSolution.wsp –url http://spwebapp –immediatestsadm –o
    
    • PowerShell
    Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://spwebapp
    Add-SPSolution "C:\WSPs\MySharePointSolution.wsp"
    
  5. Remove solution
    • Stsadm
    stsadm –o deletesolution –name MySharePointSolution.wsp
    
    • PowerShell
    Remove-SPSolution –Identity MySharePointSolution.wsp
    
  6. Activate feature
    • Stsadm
    stsadm –o activatefeature –name MyFeatureName –url http://spwebapp
    
    • PowerShell
    Enable-SPFeature –Identity MyFeatureNameOrGuid –url http://spwebapp
    
  7. Deactivate feature
    • Stsadm
    stsadm –o deactivatefeature –name MyFeatureName –url http://spwebapp
    
    • PowerShell
    Disable-SPFeature –Identity MyFeatureNameOrGuid –url http://spwebapp
    

Read more at Microsoft web site http://technet.microsoft.com/en-us/library/ee906565(v=office.15).aspx

Reference: http://patrickboom.wordpress.com/2010/05/31/using-powershell-to-deploy-sharepoint-solutions-wsp-2/

Categories: SharePoint

Leave a Reply

Your email address will not be published. Required fields are marked *