Powershell: Retrieve a WSP from SharePoint Solution Store

I’m not saying this has ever happened to me but sometimes your custom application isn’t behaving as expecting and you begin to wonder whether or not your latest deployment contains the right WSP.  Problem is…you don’t remember which WSP you ran STSADM against.  So, I figured, lets see what file is in actually in the SharePoint solution store.  Below is a Powershell script that save the file locally where you can crack it open or maybe even deploy it back to TEST :)  Yes, you can admit it, it has happened to you!

	   1:  $solutioname = "inergex.mycustomapplication.wsp"
	   2:   
	   3:  [reflection.assembly]::Loadwithpartialname("microsoft.sharepoint")
	   4:   
	   5:  $farm = [Microsoft.sharepoint.administration.spfarm]::Local
	   6:   
	   7:  $solution = $farm.Solutions[$solutioname]
	   8:  $file = $solution.SolutionFile
	   9:   
	  10:  $file.SaveAs("c:\" + $solutioname)

 

 SharePoint Rocks!
Eli

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
The question below is for testing whether you are a human visitor and to prevent automated spam submissions. The validation of your entry is case sensitive.
Image CAPTCHA
Enter the characters shown in the image.