This is the place where we need to wait for the next operation to complete the previous one.
Here is the code sample for the same :
function WaitForJobToFinish([string]$SolutionName1)
{
$JobName = "*solution-deployment*$SolutionName1*"
$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.."
}
}
No comments:
Post a Comment