Backup and download solutions in SharePoint from the configuration database

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.

Why WordPress and not SharePoint?

Many people have said to me “your using WordPress for your blog but you’re a SharePoint Consultant” and my response is typical “but why must use SharePoint – I guess you also have a problem with me using a Mac?”.

Yes I do work with SharePoint – in fact it goes beyond just working with it but we won’t go there. I have developed websites for many years and typical chosen to build these on the WordPress platform – it’s adaptable and responsive to the differing requirements and yet it doesn’t need weeks of custom development. Not only that but it was built for blogging and the user interface is more in tune to writing blog posts. Secretly I knew if I used SharePoint for my blog it would become more of a job than a hobby with all the extra work it would need.

SharePoint is just not the blogging platform for me – let’s just say when I’m blogging I want the night off!