Search This Blog

Friday 22 June 2012

Export All WSP's from Central Administration using Powershell


$dirName = "c:\Exported Solutions\"
if (!(Test-Path -path $dirName))
{
New-Item $dirName -type directory
}
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
    }
}

Result:














You can download the script here

Get a specific wsp from SharePoint Central Administration

Code Snippet :

$dirName = "c:\Exported Solutions\"
if (!(Test-Path -path $dirName))
{
New-Item $dirName -type directory
}
Write-Host Exporting solution to $dirName
$farm = Get-SPFarm
$file = $farm.Solutions.Item("hfreports.wsp").SolutionFile
$file.SaveAs($dirName + "hfreports.wsp ")


You can download the script here

No comments:

Post a Comment