none
SharePoint Farm Solution Extractor all the wsp file RRS feed

  • Question

  • Hi,

         Can be possible in sharepoint 2013 to extract all the wsp file (PowerShell Script to extract all the wsp files from current Sharepoint 2013 farm). Please suggest me as soon as possible...

    Note:- If possible than suggest in which type of powershell command to extract all the wsp file. 

    thanks

    Mukesh



    Thanks Mukesh

    Monday, August 22, 2016 6:13 AM

Answers

  • Hi Mukesh,

    Here is the powershell script where you can download and save WSps in a particular folder.

    Mention directory path where you want to save WSPs

    #Get reference to SharePoint farm
    $farm = Get-SPFarm

    #Location to save the solution files
    $loc = “D:\solutions” #replace with your file location.

    #Download all the solutions

    foreach($solution in $farm.Solutions){

    $solution = $farm.Solutions[$solution.Name]
    $file = $solution.SolutionFile
    $file.SaveAs($loc + ‘\’ + $solution.Name)
    }

    Write-Host “All the solutions are downloaded to $loc”

    MARK THIS AS ANSWER IF IT HELPS!!


    Thanks Shekhar.diary


    Monday, August 22, 2016 7:12 AM
  • Hi Mukesh,

    Please use the below code of extact all WSP files,

    (Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + “\” + $_.Name; $_.SolutionFile.SaveAs($var)}

    Get-SPFarm does just that it gets your current farm. When I put it in the ( ) that returns the farm. Then I tack on .Solutions which returns all of the solutions in the farm. From there I pipe the solutions over to old faithful ForEach-Object. ForEach-Object says do everything within the { } to each solution passed from the pipe. Within the { } I use $var = to set the variable’s value to Get-Location which returns the current location you are at in the file system. .Path returns that location. (Example output: c:\backupfolder) The + says continue to add to the $var variable. “\” adds a \ to the $var variable. Another + means keep adding to the variable. $_.Name says give me the name property of the current solution. So this ends up setting the value of $var to c:\backupfolder\mysolution.wsp assuming the solution filename was mysolution.wsp and we were running our PowerShell from the folder c:\backupfolder. Finally we have a ; which means we are all done with that line.

    We follow up setting the variable with $_.SolutionFile.SaveAs($var). $_.SolutionFile is a property of the current solution. .SaveAs is a method for saving that file. That method needs to know what filename to save the solution to. We give it $var which is the variable we just created.

    For detailed reference: http://blogs.msmvps.com/shane/2011/05/04/using-powershell-to-export-all-solutions-from-your-sharepoint-2010-farm-and-other-fun/


    Hope this help.

    Vote - if you find this helpful

    Marked as Answer - if you see this reply being an answer to the question of the thread


    Regards,

    Amjad Khan

    Blog: https://amjadk.com

    Monday, August 22, 2016 7:18 AM

All replies

  • Hi Mukesh,

    Here is the powershell script where you can download and save WSps in a particular folder.

    Mention directory path where you want to save WSPs

    #Get reference to SharePoint farm
    $farm = Get-SPFarm

    #Location to save the solution files
    $loc = “D:\solutions” #replace with your file location.

    #Download all the solutions

    foreach($solution in $farm.Solutions){

    $solution = $farm.Solutions[$solution.Name]
    $file = $solution.SolutionFile
    $file.SaveAs($loc + ‘\’ + $solution.Name)
    }

    Write-Host “All the solutions are downloaded to $loc”

    MARK THIS AS ANSWER IF IT HELPS!!


    Thanks Shekhar.diary


    Monday, August 22, 2016 7:12 AM
  • Hi Mukesh,

    Please use the below code of extact all WSP files,

    (Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + “\” + $_.Name; $_.SolutionFile.SaveAs($var)}

    Get-SPFarm does just that it gets your current farm. When I put it in the ( ) that returns the farm. Then I tack on .Solutions which returns all of the solutions in the farm. From there I pipe the solutions over to old faithful ForEach-Object. ForEach-Object says do everything within the { } to each solution passed from the pipe. Within the { } I use $var = to set the variable’s value to Get-Location which returns the current location you are at in the file system. .Path returns that location. (Example output: c:\backupfolder) The + says continue to add to the $var variable. “\” adds a \ to the $var variable. Another + means keep adding to the variable. $_.Name says give me the name property of the current solution. So this ends up setting the value of $var to c:\backupfolder\mysolution.wsp assuming the solution filename was mysolution.wsp and we were running our PowerShell from the folder c:\backupfolder. Finally we have a ; which means we are all done with that line.

    We follow up setting the variable with $_.SolutionFile.SaveAs($var). $_.SolutionFile is a property of the current solution. .SaveAs is a method for saving that file. That method needs to know what filename to save the solution to. We give it $var which is the variable we just created.

    For detailed reference: http://blogs.msmvps.com/shane/2011/05/04/using-powershell-to-export-all-solutions-from-your-sharepoint-2010-farm-and-other-fun/


    Hope this help.

    Vote - if you find this helpful

    Marked as Answer - if you see this reply being an answer to the question of the thread


    Regards,

    Amjad Khan

    Blog: https://amjadk.com

    Monday, August 22, 2016 7:18 AM