Skip to content

Instantly share code, notes, and snippets.

@masonwan
Last active November 21, 2024 04:28
Show Gist options
  • Save masonwan/d806c3697e97fd23b33dbc6615979745 to your computer and use it in GitHub Desktop.
Save masonwan/d806c3697e97fd23b33dbc6615979745 to your computer and use it in GitHub Desktop.

Problem

When install Windows on a older devices, many devices could potentially wake up the computer from the sleep mode.

It's possible to identify them using the Event Viewer. But it's always a hassle.

Solution

Run the following PowerShell in terminal to disable all devices capable to wake the computer. And then identify the devices we really want to wake the computer in Device Manager, and set thier Power Management.

$wakeDevices = powercfg -devicequery wake_armed

# Disable wake for each device
foreach ($device in $wakeDevices) {
  if ($device -ne "") {
    Write-Host "Disabling wake for: $device"
    powercfg -devicedisablewake "$device"
  }
}

Write-Host "All wake-capable devices have been disabled."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment