Wednesday, May 27, 2015

How to Download Deployed WSP files from Central Administration Using PowerShell

Sometimes we don't have any backup of .wsp files which we have already deployed in Central Administration. In order to download already deployed .wsp file from Central Administration we can use below power shell to download and save the wsp file on any path.

$SPFarm = Get-SPFarm
$getWSP = $SPFarm.Solutions.Item(“dotnetsharepoint.wsp”).SolutionFile
$getWSP.SaveAs(“C:\dotnetsharepoint.wsp”)
- See more at: http://www.dotnetsharepoint.com/2014/05/how-to-download-wsp-file-central-admin.html#sthash.PsqQHcMD.dpuf
$SPFarm = Get-SPFarm
$getWSP = $SPFarm.Solutions.Item(“PackageName.wsp”).SolutionFile
$getWSP.SaveAs(“C:\dotnetsharepoint.wsp”)

Also, below is the power shell script to download all the deployed solutions in SharePoint Farm.


#Get reference to SharePoint farm
$farm = Get-SPFarm
#Location to save the solution files
$loc = “D:\solutions” #replace with your file location. Make sure that the folder is already created/existing
#Download all the solutions
foreach($solution in $farm.Solutions){
$solution = $farm.Solutions[$solution.Name]
$file = $solution.SolutionFile
$file.SaveAs($loc + ‘\’ + $solution.Name)
}
Write-Host “All the solutions are downloaded to $loc”

Note: Just need to create solutions folder in d driver or any where else and replace that path in $loc variable in above path

$SPFarm = Get-SPFarm
$getWSP = $SPFarm.Solutions.Item(“dotnetsharepoint.wsp”).SolutionFile
$getWSP.SaveAs(“C:\dotnetsharepoint.wsp”)
- See more at: http://www.dotnetsharepoint.com/2014/05/how-to-download-wsp-file-central-admin.html#sthash.PsqQHcMD.dpuf
$SPFarm = Get-SPFarm
$getWSP = $SPFarm.Solutions.Item(“dotnetsharepoint.wsp”).SolutionFile
$getWSP.SaveAs(“C:\dotnetsharepoint.wsp”)
- See more at: http://www.dotnetsharepoint.com/2014/05/how-to-download-wsp-file-central-admin.html#sthash.PsqQHcMD.dpuf