Created
November 12, 2013 09:47
-
-
Save cchitsiang/7428213 to your computer and use it in GitHub Desktop.
Uninstall All SharePoint Solution
From http://social.technet.microsoft.com/Forums/en-US/9cc5b5c6-e728-4f48-af6c-00cf8be3d4ba/powershell-script-to-retract-remove-all-farm-solutions?forum=sharepointadminprevious
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Usage | |
If you’re saving the script to a file, say “Remove-AllSPSolutions.ps1” then remember to load the script before invoking it with: | |
. .Remove-AllSPSolutions.ps1 | |
You can uninstall all deployed solutions with the following command: | |
Uninstall-AllSPSolutions -Confirm | |
And then remove them with: | |
Remove-AllSPSolutions -Confirm | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment