powercfg problem


  1. Posts : 52
    windows 10 Pro
       #1

    powercfg problem


    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?

    Thanks
    RAC

    $try = 0
    do {
    $wake = powercfg -lastwake
    Start-Sleep -Seconds 5
    $try += 1
    Write-Host "Wake tries: $try"
    } while ($wake -eq $null)
      My Computer


  2. Posts : 42,734
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Hi, works for me- can only think maybe sthg is delaying the processing- was your system idle? But 5s is quite long.. hmm.
      My Computers


  3. Posts : 52
    windows 10 Pro
    Thread Starter
       #3

    dalchina said:
    Hi, works for me- can only think maybe sthg is delaying the processing- was your system idle? But 5s is quite long.. hmm.
    It works for me most of the time. But 2448 times 5 seconds part is 3.4 hours. Nobody was on the system. The system woke up at 8:00 AM for the next 3.4 hours every 5 seconds it failed to get a valid response from powercfg -lastwake. Yet if I open a command prompt and enter the command it works.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:53.
Find Us




Windows 10 Forums