Monday, August 5, 2013

Export Solutions from farm

Recently a client 'accidentally' deleted the solutions that we installed on their farm.
Not from SharePoint, but the actual wsp files that we copied to their server. 
These are useful to have in case someone 'accidentally' removed the solution.
We can recover installed solutions from Powershell.



$dirName = "e:\exportedfiles"

foreach ($solution in Get-SPSolution)
{
$id = $Solution.SolutionID
$title = $Solution.Name
$filename = $Solution.SolutionFile.Name

try {
$solution.SolutionFile.SaveAs("$dirName\$filename")
Write-Host " – done" -foreground green
}
catch
{
Write-Host " – error : $_" -foreground red
}
}


This will populate your $dirName with wsp files from the farm.Files are now back, and you dont need to restore the VM!