Some time we got requirement to download farm solutions and it is specially required in migrations. Below I am sharing a simple PowerShell script which can download all solutions deployed on the SharePoint Farm. You need to execute this script on SharePoint Farm with SPFarm account as this script need SharePoint Farm administrative access to execute.
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Administration”)function DownloadAllFarmSolutions()
{
#Get reference to SharePoint farm
$farm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()#Path to save the solution files, Create the folder before executing script
$path = “C:\SPSolutions”#Download all the farm solutions
foreach($spSolution in $farm.Solutions){
$spSolution = $farm.Solutions[$spSolution.Name]
$file = $solution.SolutionFile
$file.SaveAs($path + ‘\’ + $spSolution.Name)
}
}
Execute the script on PowerShell and then call the function DownloadAllFarmSolutions which will save Farm solutions on specified path.
This script has been tested on SharePoint 2010, SharePoint 2013 and SharePoint 2016.






