Export WSP files from farm

http://blogs.msdn.com/b/kaevans/archive/2011/12/05/extract-a-wsp-solution-from-sharepoint-2010.aspx
$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.

 

Nice catch. For Sandbox solutions, this would not work because this solution accesses items in the SPFarm.Solutions collection, the solutions are stored in the farm as part of the configuration database. Sandbox solutions are different because they are stored in the content database, in a document library called the Solution Gallery. If you want to access these programmatically, I would think you could use the SPList API, or Lists.asmx web service.

Export WSP files from farm