Backup and download solutions in SharePoint from the configuration database

The estimated reading time for this post is 0 minutes

The need to backup or download SharePoint solutions or WSPs from SharePoint come’s up from time to time. This usually crops up for me when upgrading client environments and they have forgotten where they put their original solutions or there is a discrepancy as to which version they installed.

To download the solutions from the configuration database (or config db) run the following PowerShell script which will save all of the solutions from SharePoint to a directory (“C:\Solutions”).

[code lang=”powershell”]

## Download and backup deployed SharePoint solutions from the config database

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$dir = "C:\Solutions\"
$solutions = Get-SPSolution

if(!$solutions){
write-host "No solutions found." -foregroundcolor Red
}else{
New-Item -ItemType directory -Path $dir -force | Out-Null
write-host "Saving solutions to $($dir)."

foreach($wsp in Get-SPSolution){
$name = $wsp.SolutionFile.Name
$wsp.SolutionFile.SaveAs("$dir\$name")
write-host "Solution ‘$($name)’ saved."
}

write-host "All solutions have been saved successfully." -foregroundcolor green
ii $dir
}
[/code]

Download

You can download the script here. Remember to review, rename and test this script before using it in a production environment.

Published by

James Callaghan

Father, blogger, consultant, SharePoint, Azure, Office 365 and PowerShell specialist, troubleshooter, geek, home brewer and would be amateur chef.

Leave a Reply