Friday, January 27, 2012

Extract WSP through C# or Powershell.

C# code extract WSP file:

SPSolutionCollection solutions = SPFarm.Local.Solutions;

foreach (SPSolution solution in solutions)
{
SPPersistedFile wspFile = solution.SolutionFile;
wspFile.SaveAs("c:\\wsp\\" + solution.Name);
}

Powershell script:
Start-Transcript "c:\wsp\transcript.txt"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$solutions = [Microsoft.SharePoint.Administration.SPFarm]::Local.Solutions;
foreach ($solution in $solutions) {
$solution.SolutionFile.SaveAs("c:\wsp\" + $solution.Name);
}
Stop-Transcript

No comments:

Post a Comment