In order to gain access to a copy of a wsp file from the Config DB, follow these steps:
Powershell:
$farm = Get-SPFarm
$file = $farm.Solutions.Item("mySolution.wsp").SolutionFile
$file.SaveAs("c:\temp\mySolution.wsp")
$file = $farm.Solutions.Item("mySolution.wsp").SolutionFile
$file.SaveAs("c:\temp\mySolution.wsp")
To Get all solutions within a farm:
(Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}
C#
using Microsoft.SharePoint
using Microsoft.SharePoint.Administration
namespace GetWSPFile
{
class GetFile
{
static void Main(string[] args)
{
SPSolutionCollection AllSolutions = SPFarm.Local.Solutions;
foreach (SPSolution solution in AllSolutions)
{
if(solution.Name =="mySolution.wsp")
{
SPPersistedFile wspFile = solution.SolutionFile;
wspFile.SaveAs("C:\" + Solution.Name);
}
}
}
}
}
No comments:
Post a Comment