Introduction

Wake on LAN (WoL) is a networking standard protocol that provides the ability to wake up the computer devices. How the WOL works is by sending a package over the LAN (also referred to as a magic packet). When the Wake-On-Lan computer has already enabled on the computer devices, the Wake-on-LAN-enabled computer devices will wait for a “magic packet” to arrive that includes the network card’s MAC address and it typically uses UDP port 7 and 9. When the device received this “magic packet”, the device will immediately wake up.

To enable the WOL on either Windows 10 client or Windows server, the network adapter or the mainboard (if it’s onboard network adapter) on the devices needs to support for WOL feature, and needs to be enabled first on the BIOS level.

To enable it on the windows OS level, we need to enable below setting on the adapter->configure->advanced. WakeOnMagicPacket -> Enabled WakeOnPattern -> Enabled

If we need to push this setting on multiple computers in the domain, we will need to set this through a GPO. However, because there’s no setting of these options directly on the GPO (as far as I know), we can use the powershell script to enable WOL on multiple computers as alternative. Be careful as enabling this Wake-On-Lan setting will disrupt the network connection on the computer devices during process.

Powershell

  • This script will check, and only enable WOL on the eligible adapter and only on adapter with name “ethernet”, you can change it if necessary##
  • This only enable the WOL on devices with support WOL, which the setting was disabled##
  • This setting unsupported to be applied to Virtual Machine ##

$wolenabled = Get-NetAdapter -Physical -Name Ethernet | Get-NetAdapterPowerManagement
if ((($wolenabled.WakeOnMagicPacket -eq "Enabled") -and ($wolenabled.WakeOnPattern -eq "Enabled")) -or ($wolenabled.WakeOnMagicPacket -eq "Unsupported") -or ($wolenabled.WakeOnPattern -eq "Unsupported"))
{
}
else
{
$wolenabled | Set-NetAdapterPowerManagement -WakeOnMagicPacket Enabled -WakeOnPattern Enabled
}

To run this script through GPO, we can create an immediately scheduler task from the GPO. This will imediately create a task scheduler, and run it (just a one-time).

  1. Copy the script into a shared folder. Ensure the folder and its file is accessible from the domain controller server, and its client that needs run this script. Create a GPO.
  2. Go to Computer Configuration -> Preferences -> Control Panel Settings -> Scheduled Tasks
  3. Create New -> Immediate Task (At least Windows 7). Provide Name and description as you want.
  4. Add System as account to ensure this task can successfully be created, and run on client computer.
  5. Tick Run with highest privileges.
  6. Go to Action, add New
  7. Change Action to Start a program
  8. Fill Program/Script to the following:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
  1. Add Arguments as below: (Change the servername, sharedfolder, and WOL script name.
-ExecutionPolicy Bypass -command "& \Server\SharedFolder\WOLScript.ps1"

Note:

  • ExecutionPolicy Bypass -> To ensure the computer bypasses the PowerShell execution policy restriction on the client computers.
  • "& symbol inside the quotes -> To ensure the script will be running immediately when its executed instead of only being loaded into memory