mandag 30. desember 2013

PowerShell: Things to check if computer keeps waking up

You may find that your Windows 8 computer wakes up by itself when in sleep mode. One reason could be a scheduled task. You can use PowerShell to list such tasks:
Get-ScheduledTask | ? {$_.Settings.WakeToRun -eq $true -and $_.State -ne "Disabled"}

And you can turn this off by running:
Get-ScheduledTask | ? {$_.Settings.WakeToRun -eq $true -and $_.State -ne "Disabled"} | % {$_.Settings.WakeToRun = $false; Set-ScheduledTask $_}

Another reason why your computer may wake by itself is connected devices. You can list those devices like this:
powercfg /devicequery wake_armed

And you can query if you computer was waked by a device by running:
powercfg /lastwake

To disable the wake option on a device you can run the command:
powercfg /devicedisablewake <devicename>

To do this on all devices you can combine the commands with PowerShell:
$DevList = (powercfg /devicequery wake_armed); if ($DevList -ne 'NONE'){foreach ($Dev in $DevList){If ($Dev -ne ''){(powercfg /devicedisablewake $Dev)}}}

Ingen kommentarer:

Legg inn en kommentar