I used this blog (http://www.sharepointbleached.com/2011/03/extract-wsp-solutions-from-sharepoint.html) to get the script.
The following simple PowerShell script will iterate through the solution store and write the WSP packages to file:
Start-Transcript “c:\wsp\transcript.txt”
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$solutions = [Microsoft.SharePoint.Administration.SPFarm]::Local.Solutions;
foreach ($solution in $solutions) {
$solution.SolutionFile.SaveAs(“c:\wsp\” + $solution.Name);
}
Stop-Transcript