SharePoint 2010–Extracting a .WSP Solution File Out of Your Farm

So any SharePoint consultant who has been out there for a while knows that sometimes you walk into a farm and it’s a mess.  Configurations aren’t right, which at least you have a good change of fixing… However, one of the more interesting situations is when you walk in and the farm is running fine, but the company has a bunch of .WSPs that are deployed to the farm and they don’t know what versions they are or what they do.  So how does one go about extracting a WSP from the farm so that we can then either deploy it to a migration farm or crack it open and reverse engineer it via a .CAB extractor?

Turns out that PowerShell makes it pretty easy for us to look like heroes.  Now why this very useful feature isn’t built into the UI I’ll never know, but if you log into the server and run these commands you’re able to quickly extract the .WSP files that have been deployed to the farm.

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

Obviously, just substitute the name of the solution you want to extract for the “solution.wsp” in the code.  And it really is just that easy.

Leave a Reply