Exporting Solutions packages (WSP files) with PowerShell

Occasionally, it can be necessary to export solution packages (WSP files) from the farm solution store. PowerShell makes this a breeze !

The script below will export all the solutions from the farm solution store (not sandboxed solutions) to a single directory:

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

## setup our output directory
$dirName = "c:\Exported Solutions"

Write-Host Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
    $id = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name

    Write-Host "Exporting ‘$title’ to …\$filename" -nonewline
    try {
        Write-Host " – done" -foreground green
        Write-Host " – error : $_" -foreground red

Running the above script results in the following output;

Exporting solutions to C:\Exported Solutions
Exporting ‘adv365 blog branding.wsp’ to …\adv365 blog branding.wsp – done
Exporting ‘adv365 portal auditing.wsp’ to …\adv365 portal auditing.wsp – done
Exporting ‘adv365 portal branding.wsp’ to …\adv365 portal branding.wsp – done
Exporting ‘adv365 portal common.wsp’ to …\adv365 portal common.wsp – done
Exporting ‘adv365 portal signin.wsp’ to …\adv365 portal signin.wsp – done
Exporting ‘adv365.sharepoint.dms.wsp’ to …\adv365.sharepoint.dms.wsp – done
Exporting ‘powerpivotfarm.wsp’ to …\powerpivotfarm.wsp – done
Exporting ‘powerpivotwebapp.wsp’ to …\powerpivotwebapp.wsp – done
Exporting ‘quote_ticker.wsp’ to …\quote_ticker.wsp – done
Exporting ‘sharepointcustomerrors.wsp’ to …\sharepointcustomerrors.wsp – done

… and the following files being created on disk:


I hope you find this useful….