1.    24 May 2016 #1
    Join Date : Mar 2016
    Posts : 28
    windows 10 Pro

    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 ComputerSystem Spec
  2.    24 May 2016 #2
    Join Date : Jan 2015
    UK, Midlands
    Posts : 11,129
    Win 10 Pro (1703)

    Hi, works for me- can only think maybe sthg is delaying the processing- was your system idle? But 5s is quite long.. hmm.
      My ComputerSystem Spec
  3.    24 May 2016 #3
    Join Date : Mar 2016
    Posts : 28
    windows 10 Pro
    Thread Starter

    Quote Originally Posted by dalchina View Post
    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 ComputerSystem Spec

 


Similar Threads
Thread Forum
Solved Fresh Windows 10 Install Won't Sleep w/ PowerCFG Configured
Hello Windows 10 Community, I'm currently in the process of finalizing my Windows 10 install by configuring all the little details I typically do, but for some reason I cannot get my computer to sleep after the specified time in the Control...
Software and Apps
Password problem or Windows Live Account problem
Cannot remember password, OR typed it in wrong on both entries. When I use the tool for recovering/resetting the password. The system takes me to a reset function, where I am able to put in a new password twice, but the screen that follows does not...
User Accounts and Family Safety
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 13:17.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums