Skip to content
Menu

Wake a Powered-Off PC - Wake-on-LAN

Sends Wake-on-LAN magic packets for the MAC addresses you list, to each local subnet or to broadcast addresses you give. It cannot confirm that a PC woke.

Wake a powered-off PC - Wake-on-LAN is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Wake a powered-off PC - Wake-on-LAN. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM or a user
NeedsPowerShell 5.1; an online PC on the same subnet as the target
Changes thingsChanges what it runs on

What It Does

The script changes things only on the network: it sends UDP broadcast packets and changes nothing on this PC. For each MAC address it builds a magic packet, six bytes of FF followed by the MAC repeated 16 times, and sends it Repeat times to each broadcast address. MAC addresses are accepted as aa:bb:cc:dd:ee:ff, aa-bb-cc-dd-ee-ff, aabb.ccdd.eeff or aabbccddeeff, in any case.

Run it on an online PC on the same subnet as the sleeping PC, because broadcasts do not cross routers. Without Broadcast, it sends to the directed broadcast address of every up IPv4 interface, from that interface, for example 192.168.1.255 for 192.168.1.20/24. With Broadcast, it sends to the addresses you give.

The script cannot confirm that a target woke up, because UDP gives no answer, so sent is all it can say. If a PC does not wake, check that Wake-on-LAN is on in its BIOS or UEFI and network adapter settings, that it is plugged into Ethernet, and that Fast Startup is not hiding a full shutdown.

Sending the same packets again is harmless, so a second run sends them again and says CHANGED.

Before You Run It

  • Collect the MAC addresses of the PCs first. The script cannot look them up.
  • Check Wake-on-LAN is turned on in each PC's BIOS or UEFI and network adapter settings.
  • Use Ethernet and a sender on the same subnet. Wi-Fi and routed networks usually do not work.
  • Use DryRun=true to list what would be sent without sending anything.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Sends UDP broadcast packets on the network; nothing changes on this PC.
  • Restart: It never restarts the machine.
  • Typical run: Under 10 seconds.
  • Example answer: "Sent 6 magic packets (3 each) for 2 MACs via 192.168.1.255:9; cannot confirm the PCs woke"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • MacAddresses: Required. MAC addresses of the PCs to wake, separated by comma, semicolon or newline. Accepts aa:bb:cc:dd:ee:ff, aa-bb-cc-dd-ee-ff, aabb.ccdd.eeff and aabbccddeeff, any case.
  • Broadcast: Optional. IPv4 broadcast address(es) to send to (for example 192.168.1.255), separated by comma or semicolon. Empty (default) uses the directed broadcast of each up IPv4 interface.
  • Port: UDP port, 1 to 65535. Default 9 (7 is the other common choice).
  • Repeat: Packets sent to each address for each MAC, 1 to 10. Default 3.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

invoke-wake-on-lan.ps1 · 866 lines · 44.3 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.