Sometimes, you are setting up a new SharePoint environment and you need to make it similar to one of the existing SharePoint farms. However, there are few custom solutions for which you don’t have appropriate .wsp file ready or you can’t figure out which version of the .wsp was deployed on the server.
You can use below script to export all SharePoint solutions from an existing farm:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Specify the directory location to export files | |
$dirName = "c:\spbackups" | |
if(!(Test-Path $dirName)){ | |
New-Item -Path $dirName -ItemType Directory -Force | |
} | |
Write-Output Exporting solutions to $dirName | |
foreach ($solution in Get-SPSolution) | |
{ | |
$id = $solution.SolutionID | |
$title = $solution.Name | |
$filename = $solution.SolutionFile.Name | |
Write-Output "Exporting ‘$title’ to …\$filename" -nonewline | |
try { | |
$solution.SolutionFile.SaveAs("$dirName\$filename") | |
Write-Output " – done" -foreground green | |
} | |
catch | |
{ | |
Write-Output " – error : $_" -foreground red | |
} | |
} |