feature(wakeup): only display connection err on last iteration
This commit is contained in:
parent
140edc1cb1
commit
cccd7ca3d6
18
wakeup.ps1
18
wakeup.ps1
@ -162,7 +162,6 @@ for ($i = $ConnectivityCheckDelay; $i -gt 0; $i--) {
|
||||
Write-Progress -Activity "Waiting for computer(s) to wake-up..." -Completed
|
||||
|
||||
# iterate computers and test connectivity
|
||||
# TODO: report error/fail only after final run
|
||||
# TODO: run connectivity test as background job
|
||||
$connCheckTotalTime = 0
|
||||
$removeFromTargetComputers.Clear()
|
||||
@ -184,10 +183,19 @@ do
|
||||
}
|
||||
if (!(Test-NetConnection -ComputerName $fqdn -Port $ConnectivityCheckPort -InformationLevel Quiet -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -ErrorVariable +connectionError))
|
||||
{
|
||||
Write-Host -ForegroundColor Red "[ERROR]"
|
||||
$connectionError | ForEach-Object {
|
||||
$errMsg = $_.ToString()
|
||||
Write-Verbose "`t(Additional information: $errMsg)"
|
||||
if (($connCheckTotalTime + $ConnectivityCheckInterval) -gt $ConnectivityCheckTimeout)
|
||||
{
|
||||
# last iteration, display 'error'
|
||||
Write-Host -ForegroundColor Red "[ERROR]"
|
||||
$connectionError | ForEach-Object {
|
||||
$errMsg = $_.ToString()
|
||||
Write-Verbose "`t(Additional information: $errMsg)"
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# more iterations pending, display 'retrying'
|
||||
Write-Host -ForegroundColor Yellow "[RETRYING]"
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user