MSTechTalk PowerShell

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.

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose.Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies.Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.