Retrieving SharePoint 2010 Farm Solutions with PowerShell

The following PowerShell script allows for saving all of the farm level solutions in a SharePoint 2010 farm.

The Script

function SPGetFarmSolutions {
	param (
		[string] $directory = $(Read-Host -prompt "Enter a directory (use ""."" for current dir)")
	)

	if ($directory.Length -lt 2) {
		$directory = [string]$pwd + "\\";
	}

	$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local;
	$solutions = $farm.Solutions;
	$solutions | ForEach-Object {
		Write-Host "Found solution $_.name";
		$_.SolutionFile.SaveAs($directory + $_.name);
	}
}

or the one liner:

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

SharePoint Solution Downloader

One of my pain points as a SharePoint “administrator” is having to deal with deployments of solution packages to my environment without the best change management. This means that I often see packages making their way in to the environment without any thought given to keeping the package in case it needs to be reapplied at a later time (Note: I’m not the only one who controls what goes into the environment).

The solution? I whipped up a Windows application so download one, several, or all of the solution packages currently stored in the farm configuration database.

I have posted the application to CodePlex @ http://spsolutiondownloader.codeplex.com/.

SharePoint Solution Downloader

The application must be run in the context of a Farm Administrator (i.e. right-click, Run As…) on a server in the farm for which you wish to download the solution package(s) from and requires the .NET Framework 3.5.

I would love some feedback from the community as to whether or not this useful. I have some other little apps in mind I could put together with the proper motivation.

Some Background on CAS Policies

Reza Alirezaei has a good post on the behind the scenes of CAS policies and SharePoint.

Check it out.

Performance Optimization WordPress Plugins by W3 EDGE