This is a handy little PowerShell snippet that I needed to use today. There were two .WSP solutions installed within the SharePoint farm and I couldn’t locate the original source code.
$farm = Get-SPFarm $solution = $farm.Solutions.Item("MySharePointSolution.wsp").SolutionFile $solution.SaveAs("C:\MySharePointSolution.wsp")