Ah, my first blogpost on this community. 🙂
I use PowerShell a lot… with a development background, I found it not that hard to get used to it and once you get the hang of it, it gives you a lot of power and possibilities.
The script below gives you an easy way of extracting all farm solutions from a SharePoint solution store. I use it a lot when doing migration projects or assessments at customers. This ensures me that I have a copy of the WSP’s which are actually deployed.
.SYNOPSIS Exports all farm solutions from a solutions store. .DESCRIPTION Exports all farm solutions from a solutions store. .NOTES File Name: Export-Solution.ps1 Version : 1.0 .PARAMETER OutputPath Specifies the location where the exported solutions are saved. .EXAMPLE PS > .\Export-Solution.ps1 -OutputPath "c:\install\WSPExport" Description ----------- This script exports all existing solutions in the local solutions store to c:\install\WSPExport. #> [CmdletBinding()] param( [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false)] [string]$OutputPath ) if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -EA SilentlyContinue) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell } # Create the provided path if it doesn't exist if (!(Test-Path -Path $OutputPath)) { New-Item $OutputPath -ItemType directory >> $null } # Append a trailing backslash if needed if (!$OutputPath.EndsWith("\",$false,$null)) { $OutputPath += "\" } # Iterate over the solutions and save them to the provided output path Write-Host "Exporting farm solutions to $OutputPath" foreach ($solution in Get-SPSolution) { $id = $solution.SolutionId $title = $solution.Name $filename = $solution.SolutionFile.Name Write-Host -NoNewline "Exporting '$title' to ...\$filename" try { $solution.SolutionFile.SaveAs("$folder\$filename") Write-Host -ForegroundColor Green " - OK" } catch { Write-Host -ForegroundColor Red " - error : $_" } }