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