Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}
}