Use this PowerShell script to uninstall and remove all the custom solutions From http://sharepoint247.wordpress.com/2013/04/09/powershell-script-to-remove-all-custom-solutions-from-sharepoint-farm-solutions-store/
#########################################################################################################
#### Author: Rahul G. Babar ####
#### Purpose: Use this PowerShell script to uninstall and remove all the custom solutions from ####
#### the SharePoint farm solution store. ####
#### Usage Example: .\CleanupFarmSolutionStore.ps1 -Confirm:$false ####
#########################################################################################################
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[bool]$Confirm
)
function LoadSharePointPowerShellEnvironment
{
write-host "Setting up PowerShell environment for SharePoint" -foregroundcolor Yellow
write-host
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
write-host "SharePoint PowerShell Snapin loaded." -foregroundcolor Green
write-host
}
LoadSharePointPowerShellEnvironment
$AdminServiceName = "SPAdminV4"
$WasAdminServiceRunning = $true;
if ($(Get-Service $AdminServiceName).Status -eq "Stopped")
{
write-host "[[STEP]] Starting SharePoint Administration Service since it is not already started." -foregroundcolor Yellow
write-host
$WasAdminServiceRunning = $false;
Start-Service $AdminServiceName
write-host "[[STEP]] SharePoint Administration Service Started" -foregroundcolor Green
write-host
}
Start-SPAssignment -Global;
$solutions = Get-SPSolution
foreach($solution in $solutions)
{
if($solution -ne $null)
{
$solutionName = $solution.Name
if($solution.Deployed)
{
Write-Host "Uninstalling solution $solutionName..." -ForegroundColor Yellow
write-host
if($solution.DeployedWebApplications.Count -gt 0)
{
Uninstall-SPSolution -Identity $solution -AllWebApplications -Confirm:$Confirm
}
else
{
Uninstall-SPSolution -Identity $solution -Local:$true -Confirm:$Confirm
}
do
{
Start-Sleep 5;
$solution = Get-SPSolution $solution;
} while($solution.JobExists -or $solution.Deployed)
Write-Host "Unistalled solution $solutionName successfully." -ForegroundColor Green
write-host
}
Write-Host "Removing solution $solutionName..." -ForegroundColor Yellow
write-host
Remove-SPSolution -Identity $solution -Confirm:$Confirm
do
{
Start-Sleep 5;
$solution = Get-SPSolution $solution -ErrorAction SilentlyContinue
} while($solution -ne $null)
Write-Host "Removed solution $solutionName successfully." -ForegroundColor Green
write-host
}
}
Stop-SPAssignment -Global;
if (-not $WasAdminServiceRunning)
{
write-host "[[STEP]] Stopping SharePoint Administration Service." -foregroundcolor Yellow
write-host
Stop-Service $AdminServiceName
write-host "[[STEP]] SharePoint Administration Service Stopped." -foregroundcolor Green
write-host
}
Write-Host "Farm solution store cleanup finished" -ForegroundColor Green
Script Usage:
1. Copy paste the below script in a text file and save the file as say “CleanupFarmSolutionStore.ps1″.
2. Run SharePoint 2010 Management Shell and change directory to where you saved above file.
3. Run command as > .\CleanupFarmSolutionStore.ps1 -Confirm $false
Note: Setting parameter -Confirm to false will not ask for confirmation before uninstalling and removing the solution from farm solution store. Set it to true for asking the confirmation.