Wednesday, February 13, 2013

Export Solution Packages (WSP) from SharePoint farm using PowerShell

When we deploy an updated version of a solution package, it’s better to take a backup of the currently deployed version. Although we can build the appropriate version from the version controlling system if there any, it’s always safer to get the current working solution package which is proven working in that environment.

Following script extracts a set of solution packages you wish to download from the farm.

  1. $packages = @("solution1.wsp","solution2.wsp")
  2. $solutionPath = "C:\Backup\"
  3.  
  4. foreach ($solution in (Get-SPFarm).Solutions)
  5. {
  6.      if($packages -contains $solution.Name)
  7.      {
  8.          $filename = $Solution.SolutionFile.Name
  9.          $solution.SolutionFile.SaveAs($solutionPath + $filename)
  10.      }    
  11. }

No comments: