From 29a0a59ee1a49663572c582e08995e88c59bb475 Mon Sep 17 00:00:00 2001 From: ccoulson Date: Tue, 26 Apr 2011 19:25:47 +0000 Subject: [PATCH] Updated deployment scripts to delete any existing aborted jobs before running --- .../Deploy.ps1 | 16 ++++++++++++++-- .../UnDeploy.ps1 | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Deploy.ps1 b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Deploy.ps1 index 11290bb..f86dd7a 100644 --- a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Deploy.ps1 +++ b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Deploy.ps1 @@ -20,8 +20,18 @@ } } +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() + } +} + - $url=$args[0] $solutionName="Visigo.Sharepoint.FormsBasedAuthentication.wsp" $featureName="FBAManagement" @@ -31,6 +41,8 @@ $solutionPath=$pwd.ToString() + "\" + $solutionName Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue +DeleteTimerJob($SolutionName) + Write-Host 'Going to add solution' Add-SPSolution $solutionPath @@ -38,7 +50,7 @@ Write-Host 'Going to install solution to all web applications' Install-SPSolution –identity $solutionName –allwebapplications –GACDeployment Write-Host 'Waiting for job to finish' -WaitForJobToFinish +WaitForJobToFinish($SolutionName) Write-Host 'Going to enable Feature' Enable-spfeature -identity $featureName -confirm:$false -url $url diff --git a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/UnDeploy.ps1 b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/UnDeploy.ps1 index 641ba8b..ab2130c 100644 --- a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/UnDeploy.ps1 +++ b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/UnDeploy.ps1 @@ -20,6 +20,17 @@ } } +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] @@ -31,6 +42,8 @@ $featureExists = Get-SPSolution $solutionName -ErrorAction SilentlyContinue if ($featureExists) { + DeleteTimerJob($solutionName) + Write-Host 'Going to disable feature' disable-spfeature -identity $featureName -confirm:$false -url $url @@ -41,7 +54,7 @@ if ($featureExists) Uninstall-SPSolution -identity $solutionName -allwebapplications -confirm:$false Write-Host 'Waiting for job to finish' - WaitForJobToFinish + WaitForJobToFinish($solutionName) Write-Host 'Going to remove solution' Remove-SPSolution –identity $solutionName -confirm:$false