SharePoint 2010 Retract and Remove Projects using Powershell Script
Sometimes you need to retract and remove multiple wsp. If you will do it manually then its a time taking process. So here is a power shell script that will help you surely.
clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell
function RetractAndRemoveSolution {param ($SolutionPackageName, $DeployedGlobally)
$solution = Get-SPSolution | where-object {$_.Name -eq $SolutionPackageName}
# check to see if solution package has been installed
if ($solution -ne $null)
{
if($solution.Deployed -eq $true)
{
if( $DeployedGlobally -eq $true)
{
Uninstall-SPSolution -Identity $SolutionPackageName -Local -Confirm:$False
}
else
{
Uninstall-SPSolution -Identity $SolutionPackageName -AllWebApplications -Local -Confirm:$False
}
}
Remove-SPSolution -Identity $SolutionPackageName -Confirm:$false
}
}
iisreset
RetractAndRemoveSolution "abc.wsp" $false
iisreset
clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell
function RetractAndRemoveSolution {param ($SolutionPackageName, $DeployedGlobally)
$solution = Get-SPSolution | where-object {$_.Name -eq $SolutionPackageName}
# check to see if solution package has been installed
if ($solution -ne $null)
{
if($solution.Deployed -eq $true)
{
if( $DeployedGlobally -eq $true)
{
Uninstall-SPSolution -Identity $SolutionPackageName -Local -Confirm:$False
}
else
{
Uninstall-SPSolution -Identity $SolutionPackageName -AllWebApplications -Local -Confirm:$False
}
}
Remove-SPSolution -Identity $SolutionPackageName -Confirm:$false
}
}
iisreset
RetractAndRemoveSolution "abc.wsp" $false
iisreset
Comments
Post a Comment