These two are cousins. The first will export a single solution (wsp) file. The second script will hoover them all up. I use these basically every day.
Add-PSSnapin Microsoft.SharePoint.Powershell
$farm = Get-SPFarm
$file = $farm.Solutions.Item("some.solution.wsp").SolutionFile
$file.SaveAs("c:\bk\some.solution.wsp")
***
Add-PSSnapin Microsoft.SharePoint.Powershell
## setup our output directory
$dirName = "f:\installations\solutions"
Write-Host Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
{
$id = $Solution.SolutionID
$title = $Solution.Name
$filename = $Solution.SolutionFile.Name
Write-Host "Exporting ‘$title’ to …\$filename" -nonewline
try {
$solution.SolutionFile.SaveAs("$dirName\$filename")
Write-Host " – done" -foreground green
}
catch
{
Write-Host " – error : $_" -foreground red
}
}
No comments:
Post a Comment