Export SharePoint solutions using PowerShell

Here is a way you can export you farm’s solutions (WSP) using PowerShell:

foreach($solution in Get-SPSolution)
{
    try
        {
        $filename = $solution.Name;
        $solution.SolutionFile.SaveAs(“C:\MySolutions\$filename”)
        }
    catch
        {
        Write-Host “-error:$_”-foreground red
        }
}