Wake on LAN for Hyper-V Guests

When you turn your VM off, it’s off.  As in off-off, off: equivalent to powering it off and pulling out all the cables.  This is why you can’t use Wake on LAN (WoL) for Hyper-V guests because the network adaptor for the VM is off-off.  Which is annoying if you have a bunch of VMs that you use on a regular basis; to boot them all you have to first RDP onto the Hyper-V host and then boot each one in turn – I know, I know, a real first world problem – but it annoys me!  There are a couple of products available to help with this but they are all pretty overpriced in my opinion, especially as they provide something so simple.

WoL is pretty simple: it’s a UDP broadcast to the entire network, usually on port 7, using something called a “magic packet”.  This packet contains the MAC address of the computer to start (amongst other data).  A network adaptor listens out for these packets and reacts by powering on the computer; this all happens within the network card and the computer never gets involved (it’s off-off remember).  WoL doesn’t wait for a response, there’s no encryption/security for it, and it has no additional options/configurations other than this.

This simplicity is great news though because it means that PowerShell can be used to recreate the missing WoL functionality for Hyper-V guests.  The below script sits on your Hyper-V host listening for magic packets.  When it receives one it checks to see if the MAC Address contained matches the MAC Address of one of the VMs that it is hosting, if so it turns it on.  Simple.

With this script I can now take out my Windows Phone, open the Wake-on-LAN app, send the magic packets, and boot up my entire lab before I’ve even made it up the stairs to my office   🙂


Set the script to run permanently on your Hyper-V host, as per the above screenshot.  Upon start the code will enumerate the MAC Addresses for all VMs detected locally and will then sit in the background reading any magic packet that it sees go out across the network and react accordingly.  All informational and error messages are written out to the console window.
  • UDP port 7 should opened on your Windows Server firewall – not usually a requirement because WoL is processed by the hardware, but here we are having to process it within the operating system.
  • PowerShell execution policy will need to be set to allow the script to run
  • The script currently runs in a logged on session, so a user session needs to stay open (I’ll attempt to address this in future versions).  I have my server logged on and locked to accommodate this.
  • A WoL app on your phone and/or computer to send the requests.  Some apps require specifying the IP address of the computer as well as it’s MAC Address.  If this is the case you can either specify the IP of your Hyper-V host or use
The script is very much a work in progress project at the moment, but please try it and feedback to me any issues you have, or any other feedback, via the comments at the bottom.  As I improve it I’ll update this blog.  I’ve only tested the script on Windows Server 2016, using a non-admin account.