Skip to main content

I am trying to create a worklet that will enable  Wake-on-LAN on every network adapter on Windows 11.  Here is the script.

# Enable Wake-on-LAN on all network interfaces

# Function to enable WoL
Function Enable-WakeOnLAN {
# Get all network adapters
$adapters = Get-NetAdapter -Physical | Where-Object { $_.Status -eq "Up" }

foreach ($adapter in $adapters) {
Write-Host "Configuring adapter: $($adapter.Name)" -ForegroundColor Green

try {
# Enable "Wake on Magic Packet"
Set-NetAdapterAdvancedProperty -Name $adapter.Name -RegistryKeyword "WakeOnMagicPacket" -RegistryValue 1 -ErrorAction Stop

# Enable "Wake on Pattern Match" (optional, depending on requirements)
Set-NetAdapterAdvancedProperty -Name $adapter.Name -RegistryKeyword "WakeOnPattern" -RegistryValue 1 -ErrorAction Stop

# Ensure the "Shutdown Wake-On-Lan" setting is enabled
Set-NetAdapterPowerManagement -Name $adapter.Name -AllowWakeArmed $true -WakeOnMagicPacket $true -ErrorAction Stop

Write-Host "Wake-on-LAN enabled for adapter: $($adapter.Name)" -ForegroundColor Cyan
} catch {
Write-Host "Failed to configure adapter: $($adapter.Name). Error: $_" -ForegroundColor Red
}
}
}

# Run the function
Enable-WakeOnLAN

It is failing with this message.

Configuring adapter: Ethernet
Failed to configure adapter: Ethernet. Error: No matching MSFT_NetAdapterAdvancedPropertySettingData objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetAdapterAdvancedPropertySettingData class on the CIM server: SELECT * FROM MSFT_NetAdapterAdvancedPropertySettingData WHERE ((Name LIKE 'Ethernet')) AND ((RegistryKeyword = 'WakeOnMagicPacket')). Verify query parameters and retry.

 

Hi ​@slammert !

I've used WoL before with some success directly through Powershell PsSessions. Passing a Magic Packet to a disconnected device via a Worklet however won’t be possible since the Automox agent would need to be a connected state first and able to receive commands before it can run any Worklet code.

There might be some workarounds like issuing the Worklet to an online jump box on the same network, that device sends the WoL package via a PSsession, but I haven't tried this though!

While this doesn’t solve for your immediate need, I opened a feature request on your behalf for Wake On Lan capabilities with our Product team.

If you could share some use cases on why Wake On Lan would be beneficial to you and your team, please do share and I’ll get those added to the feature request.


Thanks and have a great day!


Thanks for the insight John.

 


Reply