Problem Statement:
When you reach to a SharePoint server which already has a custom solution (.wsp) deployed but you don't have that .wsp solution available on file system and you need the .wsp solution.
Reason:
When you deploy any solution (.wsp) in SharePoint, it stores in database not file system.
Solution:
You can use below power shell script to download these .wsp files.
-For single solution file
#Get reference to SharePoint farm
$SPFarmVar = Get-SPFarm
#Get reference to deployed SharePoint Solution file SolutionPackage.wsp
$SPWSPVar = $SPFarmVar.Solutions.Item("SolutionPackage.wsp").SolutionFile
#Saving SolutionPackage.wsp to root on C: Drive
$SPWSPVar.SaveAs("C:\SolutionPackage.wsp")
-For all deployed solution files
#Get reference to SharePoint farm
$SPFarmVar = Get-SPFarm
When you reach to a SharePoint server which already has a custom solution (.wsp) deployed but you don't have that .wsp solution available on file system and you need the .wsp solution.
Reason:
When you deploy any solution (.wsp) in SharePoint, it stores in database not file system.
Solution:
You can use below power shell script to download these .wsp files.
#Get reference to SharePoint farm
$SPFarmVar = Get-SPFarm
#Get reference to deployed SharePoint Solution file SolutionPackage.wsp
$SPWSPVar = $SPFarmVar.Solutions.Item("SolutionPackage.wsp").SolutionFile
#Saving SolutionPackage.wsp to root on C: Drive
$SPWSPVar.SaveAs("C:\SolutionPackage.wsp")
-For all deployed solution files
#Get reference to SharePoint farm
$SPFarmVar = Get-SPFarm
#Download all the solutions. Please make sure WSPs folder exist on C:
foreach ($solution in $SPFarmVar.Solutions)
{
$solution = $SPFarmVar .Solutions[$solution.Name]
$solutionFile = $solution.SolutionFile
$solutionFile.SaveAs('C:\WSPs' + $solution.Name)
}
$solutionFile = $solution.SolutionFile
$solutionFile.SaveAs('C:\WSPs' + $solution.Name)
}
That's it folks :)
..::Keep on SharePointing::..
Good job Shahid . . . Keep sharing you knowledge.
ReplyDelete