Deploy SharePoint Solution Packages (WSP) with PowerShell and STSADM
SharePoint solution packages (wsp) can be managed using either STSADM command line tool (in MOSS 2007) or with PowerShell cmdlets with SharePoint 2010 (such as deploy solution package with PowerShell). This article gives the reference for Managing SharePoint solutions using both of them with examples.
To add a solution package to the farm:
Add wsp with stsadm: stsadm -o addsolution -filename mysolution.wsp
Add SharePoint solution using PowerShell: Add-SPSolution “mysolution.wsp”
Add-SPSolution – MSDN Reference
Install/Deploy a Solution to the Farm:
STSADM command for WSP deployment: stsadm -o deploysolution -name mysolution.wsp -url https://mysharepointsite -allowgacdeployment -immediate
SharePoint 2010 PowerShell to deploy/install WSP:
Install-spsolution -identity mysolution.wsp -webapplication https://mysharepointsite -gacdeployment -force
Upgrade an existing solution:
Update WSP solution with STSADM: stsadm -o upgradesolution -name mySolution.wsp -filename “C:\MySolution.wsp” -immediate
PowerShell cmdlet to update solution in SharePoint 2010:
Update-SPSolution -Identity <solution file name>.wsp -LiteralPath C:\mysoln.wsp -GACDeployment
or
$solution = Get-SPSolution -Identity c0e31dec-294d-4f2d-9ae4-f2e637
Update-SPSolution $solution -LiteralPath "d:\newsolution.wsp" -Force -GACDeployment
Retract/uninstall a Solutions from the Farm:
Retract solution with STSADM: stsadm -o retractsolution -name mySolution.wsp -url https://mysharepointsite -immediate
Retract/uninstall SharePoint solution with PowerShell:
Uninstall-SPSolution -Identity <solution-file-name>.wsp -WebApplication https://mysharepointsite
or
$solution = Get-SPSolution -Identity c0e31dec-294d-4f2d-9ae4-f2e637
Uninstall-SPSolution $solution -WebApplication "SharePoint - 8080"
$solution = Get-SPSolution -Identity c0e31dec-294d-4f2d-9ae4-f2e637
Uninstall-SPSolution $solution -AllWebApplications
$solution = Get-SPSolution -Identity c0e31dec-294d-4f2d-9ae4-f2e637
Uninstall-SPSolution $solution
Remove/Delete a solution from the Farm:
Delete WSP solution with STSADM: stsadm -o deletesolution -name mySolution.wsp
Remove Farm solution in SharePoint 2010 with PowerShell: Remove-SPSolution -Identity mySolution.wsp
If you don’t know the Name, then get the solution, and remove it:
$Solution = Get-SPSolution -Identity d0e11dec-293d-4c2d-9a24
Remove-SPSolution $solution
Get List of installed Solutions in the Farm: Get-SPSolution
Export/Save Solution Packages to WSP with PowerShell:
$solution = Get-SPSolution -Identity c0e31dec-294d-4f2d-9ae4
$solution.SolutionFile.SaveAs("c:\Mysolution.wsp")