Scenario/Problem: You need to retract a deployed solution from a web application or global deployment.
Solution: Use the UnInstall-SPSolution
cmdlet with a solution variable.
The Uninstall-SPSolution
cmdlet enables you to retract a specific solution that was previously deployed. Use this in conjunction with the Get-SPSolution
cmdlet (explained in a previous section), as shown in Listing 9.5.
$solution = Get-SPSolution
-Identity c0e31dec-294d-4f2d-9ae4-f2e637c766bd
Uninstall-SPSolution $solution -WebApplication "SharePoint - 80"
Providing the -WebApplication
parameter retracts the solution from the specified web application (assuming that the solution was deployed to that web application and has resources scoped at the web application level). You also can retract the solution from all web applications, as shown in Listing 9.6.
$solution = Get-SPSolution
-Identity c0e31dec-294d-4f2d-9ae4-f2e637c766bd
Uninstall-SPSolution $solution -AllWebApplications
If the solution is installed globally, all you need to provide to the Uninstall-SPSolution
cmdlet is the solution identity, as shown in Listing 9.7.
$solution = Get-SPSolution
-Identity c0e31dec-294d-4f2d-9ae4-f2e637c766bd
Uninstall-SPSolution $solution
3.133.131.168