Export SharePoint solutions (.wsp) from SharePoint farm

Sometimes, you are setting up a new SharePoint environment and you need to make it similar to one of the existing SharePoint farms. However, there are few custom solutions for which you don’t have appropriate .wsp file ready or you can’t figure out which version of the .wsp was deployed on the server.

You can use below script to export all SharePoint solutions from an existing farm:

#Specify the directory location to export files
$dirName = "c:\spbackups"
if(!(Test-Path $dirName)){
New-Item -Path $dirName -ItemType Directory -Force
}
Write-Output Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
{
$id = $solution.SolutionID
$title = $solution.Name
$filename = $solution.SolutionFile.Name
Write-Output "Exporting ‘$title’ to …\$filename" -nonewline
try {
$solution.SolutionFile.SaveAs("$dirName\$filename")
Write-Output " – done" -foreground green
}
catch
{
Write-Output " – error : $_" -foreground red
}
}

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 )

Connecting to %s