Share via


PowerShell: Download SharePoint solutions

Introduction

This article will explain how to download/backup/export deployed WSP solutions from SharePoint farm. All downloaded solutions will be save in script execution location.

Applies To

The examples demonstrated below are tested with and apply to the following versions of SharePoint:

  • SharePoint 2019
  • SharePoint 2016
  • SharePoint 2013
  • SharePoint 2010

Power-Shell script to download deployed WSP solutions

Login to SharePoint sever and open the power-shell command prompt as run as administrator and run below script by saving in .ps1 file.

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
#Get Current location
$downloadLocation=Get-Location 
If($downloadLocation.Path -ne $null)
{
    Try
    {
        $farm = Get-SPFarm
        Foreach($solution in $farm.Solutions)
        { 
            Try
            {
                Write-Host "Downloading solution $($solution.Name)"
                $filename = $solution.SolutionFile.Name
                $location=$downloadLocation.Path + "\" +  $filename
                $solution.SolutionFile.SaveAs($location)
            }
            Catch
            {
                Write-Host "Error while downloading the solution "  $solution " - "  $_.Exception.Message -f Yellow
            }
        }
    }
    Catch
    {
        Write-Host "Error while getting the farm - "  $_.Exception.Message -f Yellow
    }
}
Else
{
    Write-Host "Not find the download location path: "  $downloadLocation -f Cyan
}

Note: All downloaded solutions will be save in script execution location.