Extract and Download All Installed Farm Solution Packages (WSP Files) in SharePoint

There were many solution packages installed in my current SharePoint environment. During a server replacement we noticed that the WSP file for a particular solution is missing in TFS! (Our version control repository!)

To extract and download all installed solution WSP files, use these PowerShell scripts:

Export all Farm Solutions (WSP) from central admin with PowerShell in SharePoint:
$dirName = "c:\Solutions"
foreach ($solution in Get-SPSolution)
{
    $id = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name
    $solution.SolutionFile.SaveAs("$dirName\$filename")
}
 
Download farm solution WSP in SharePoint 2013
If you want to download a particular solution, use this PowerShell Script:
$farm = Get-SpFarm
$SolutionFile = $farm.Solutions.Item("SolutionName.wsp").SolutionFile
$SolutionFile.SaveAs("D:\SolutionFile.wsp")

Download SharePoint solution from farm in SharePoint 2007:
[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Get Farm object
[Microsoft.SharePoint.Administration.SPFarm]$farm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()

#Create a Directory for Solutions
if ( (Test-Path -path "c:\Solutions\") -ne $True)
{
 New-Item c:\Solutions\ -type directory
}

$dirName = "c:\Solutions"

foreach ($solution in $farm.Solutions)
{   
    Write-Host "Downloading solution $($Solution.Name)"
    $filename = $Solution.SolutionFile.Name
    $solution.SolutionFile.SaveAs("$dirName\$filename")
}  

1 comment:

  1. Thanks for nice article about "Want to Extract the .WSP file from installed Solutions in SharePoint?"

    Regards
    http://www.sharepoint.inf4web.com

    ReplyDelete

Please Login and comment to get your questions answered!

Powered by Blogger.