Skip to main content
Question

Worklet - Enable Wake-on-LAN


Forum|alt.badge.img

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.

 

2 replies

JohnG-Automox
Forum|alt.badge.img
  • Automox Employee
  • 118 replies
  • January 28, 2025

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!


Forum|alt.badge.img
  • Author
  • Novice
  • 19 replies
  • January 28, 2025

Thanks for the insight John.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings