I have a powershell script that calls powercfg -lastwake. Every now and then it will not return any data. The code below
Checks the return value $wake for null. If null it calls powercfg again. The other day I checked the system and the $try was at 2448. I did a ctrl-c which killed the powershell script. I then typed powershell -lastwake and got a good result.
My question is why does it some times fail to return an data?
$try = 0
$wake = powercfg -lastwake
Start-Sleep -Seconds 5
$try += 1
Write-Host "Wake tries: $try"
} while ($wake -eq $null)