PowerShell script to download all Farm solutions in SharePoint Farm

Recently when i was preparing a SharePoint Farm for upgrade which has lot of custom and 3rd party farm solutions, I have to download or some how gather all those .wsp files to move to new server farm. I had rough time gathering all the wsp’s until i stumble upon this script which download all farm solutions in a SharePoint farm to a location or file drive you specify. It saved a lot of time for me. It is a handy script to have while performing upgrades/migrations.


#PowerShell script to download all Farm solutions in a SharePoint farm

#Get reference to SharePoint farm
$farm = Get-SPFarm

#Location to save the solution files
$loc = “D:\solutions” #replace with your file location. Make sure that the folder is already created/existing

#Download all the solutions

foreach($solution in $farm.Solutions){

$solution = $farm.Solutions[$solution.Name]
$file = $solution.SolutionFile
$file.SaveAs($loc + ‘\’ + $solution.Name)

Write-Host “All the solutions are downloaded to $loc”