Taylohtio/CKS.FormsBasedAuthentication/UnDeploy.ps1

75 lines
1.8 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function WaitForJobToFinish([string]$SolutionFileName)
{
$JobName = "*solution-deployment*$SolutionFileName*"
$job = Get-SPTimerJob | ?{ $_.Name -like $JobName }
if ($job -eq $null)
{
Write-Host 'Timer job not found'
}
else
{
$JobFullName = $job.Name
Write-Host -NoNewLine "Waiting to finish job $JobFullName"
while ((Get-SPTimerJob $JobFullName) -ne $null)
{
Write-Host -NoNewLine .
Start-Sleep -Seconds 2
}
Write-Host "Finished waiting for job.."
}
}
function DeleteTimerJob([string]$SolutionFileName)
{
$JobName = "*solution-deployment*$SolutionFileName*"
$job = Get-SPTimerJob | ?{ $_.Name -like $JobName }
if ($job -ne $null)
{
Write-Host 'Existing Timer job found. Deleting'
$job.Delete()
}
}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$url=$args[0]
$solutionName="cks.fba.wsp"
$featureName="FBAManagement"
$featureExists = Get-SPSolution $solutionName -ErrorAction SilentlyContinue
if ($featureExists)
{
DeleteTimerJob($solutionName)
if ($url)
{
$feature = Get-SPFeature -Site $url | where { $_.DisplayName -eq $featureName }
if ($feature)
{
Write-Host 'Going to disable feature'
disable-spfeature -identity $featureName -confirm:$false -url $url
}
}
Write-Host 'Going to uninstall feature'
uninstall-spfeature -identity $featureName -confirm:$false -force
Write-Host 'Going to uninstall solution'
Uninstall-SPSolution -identity $solutionName -allwebapplications -confirm:$false
Write-Host 'Waiting for job to finish'
WaitForJobToFinish($solutionName)
Write-Host 'Going to remove solution'
Remove-SPSolution identity $solutionName -confirm:$false
}
else
{
Write-Host 'Solution not installed'
}