Wednesday, April 23, 2014

Exporting deployed WSP's of your SP Farm

If you want to get wsp out of deployed WSP's in your fram, execute below power shell code.

Copy below lines of code to a power shell file. i.e., file with extention "ps1" and go to windows powershell command or SharePonit's and run the prepared file. 

## setup our output directory
$dirName = "c:\Exported 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
}
}

Example to run this script.
1. I copied the code to file name "ExportWSP.ps1" and saved in location C:\
2. i opened SharePoint's management power shell or windows power shell and just typed the path as "C:\ExportWSP.ps1" 
3. Now all the exported wsp's will be in the path that i specified in the code. i.e., in my case it is "C:\Exported Solutions"


Happy Codding :)

No comments:

Post a Comment