Thursday, April 16, 2015

Extract a WSP Solution from SharePoint 2010

Background
A customer of mine had a scenario where they needed to download a WSP from SharePoint 2010.  In the Central Administration screen, a link is not available for you to download the WSP solution.


Likewise, with stsadm, there’s not a command to download a solution.

Implementation
I could have written this with a C# console application, but I’ve been playing with PowerShell and found that the 3 lines of PowerShell code that it takes is much easier than trying to deploy a binary to a customer’s environment.

$farm = Get-SPFarm
$file = $farm.Solutions.Item("extendeddiagnosticproviders.wsp").SolutionFile
$file.SaveAs("c:\temp\extendeddiagnosticproviders.wsp")

Note that in order to run this command, you need to be a member of the Farm Administrators group and have permission to the configuration database.  To configure the permissions for SQL, I recommend using Add-SPShellAdmin.

1 comment: