Skip to content

Commit

Permalink
Merge pull request #1268 from simoncroak/master
Browse files Browse the repository at this point in the history
Update Wait-RemoteSitecoreJob.ps1
  • Loading branch information
AdamNaj authored Jul 25, 2024
2 parents adb429c + ff052af commit f4adcde
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Modules/SPE/Wait-RemoteSitecoreJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
[pscustomobject]$Session,

[ValidateNotNull()]
[string]$Id,
[string[]]$Ids,

[int]$Delay = 1
)
Expand Down Expand Up @@ -77,17 +77,22 @@
}
}

$keepRunning = $true
while($keepRunning) {
$response = Invoke-RemoteScript -Session $session -ScriptBlock $doneScript
if($response -and $response.IsDone) {
$keepRunning = $false
Write-Verbose "Polling job $($response.Name). Status : $($response.Status)."
Write-Verbose "Finished polling job $($id)."
Invoke-RemoteScript -Session $session -ScriptBlock $finishScript
} else {
Write-Verbose "Polling job $($response.Name). Status : $($response.Status)."
$keepRunning = 0
while($keepRunning -ne $Ids.Count) {
foreach ($id in $Ids)
{
$response = Invoke-RemoteScript -Session $session -ScriptBlock $doneScript
if($response -and $response.IsDone) {
$keepRunning++
Write-Verbose "Polling job $($response.Name). Status : $($response.Status)."
Write-Verbose "Finished polling job $($id)."
} else {
Write-Verbose "Polling job $($response.Name). Status : $($response.Status)."
}
}
if ($keepRunning -ne $Ids.Count) # Only sleep if we're not 'done' waiting for jobs
{
Start-Sleep -Seconds $Delay
}
}
}
}

0 comments on commit f4adcde

Please sign in to comment.