Uninstall all SharePoint 2010 solutions through PowerShell in order to demonstrate. I often need to demolish and rebuild the SharePoint 2010 environment. What I often need to do is remove all of the SharePoint solutions installed in the demo development environment. Here is the PowerShell script. It saves me a lot of time. I hope I can help you, too.
Script:
function uninstall-allspsolutions { param ( [switch] $Local, [switch] $Confirm ) Start-spassignment-global; foreach ($solution in (get-spsolution | Where-object {$_. Deployed}) { write-host "uninstalling solution" $solution. Name; if ($solution. Deployedwebapplications.count-gt 0) { uninstall-spsolution $solution –allwebapplications-local: $Local-Confirm: $Confirm; } else { uninstall-spsolution $solution-local: $Local-confirm: $Confirm; } Do { Start-sleep 5; $solution = Get-spsolution $solution; } while ($solution. Jobexists-and $solution. Deployed) } Stop-spassignment-global;} function remove-allspsolutions { param ( [switch] $Confirm ) get-spsolution | Where-object {!$_. Deployed} | Remove-spsolution-confirm: $Confirm}
Usage: Suppose you save the script to a file, say Remove-allspsolutions.ps1, and then call it in PowerShell, remember to write it in front:
. \remove-allspsolutions.ps1
You can use the following command to uninstall the solution for all deployments:
Uninstall-allspsolutions-confirm
and remove them:
Remove-allspsolutions-confirm
Uninstall all SharePoint 2010 solutions from PowerShell