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 {
        $solution.SolutionFile.SaveAs("$dirName\$filename")
        Write-Host " – done" -foreground green
    }
    catch
    {
        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:

image

I hope you find this useful….

About these ads

2 Responses to Exporting Solutions packages (WSP files) with PowerShell

  1. James Boman says:

    Nice one – Thanks. This works well, working on an enhancement to this to install and deploy them in a different farm.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: