Wake-On-LAN (WOL) with Windows and PowerShell

Wake-On-LAN is a networking standard that lets you wake up a computer from either a sleeping mode or a completely off mode by sending a network package through the network. It could be a very convenient technique to have in your daily work.

So how do we use it to wake up an off computer if that computer is equipped with the WOL capability?

The easiest and most effective way is to go through the network device that connects the computer to the network directly. If the network switch you are using is a manageable one, it usually offers a dashboard that allows you to send the Wake-On-LAN packets right from its port.

If not, the next available useful tool would be using PowerShell. This blog post from PDQ explains the details of how you can use PowerShell to send the Wake-on-LAN network packet through the network to wake up a sleeping computer.

In short, if you know the MAC address of a computer, you can use the following script to wake it up.

$Mac = "dc:4a:3e:76:43:e8"
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray  * 16)
$UdpClient = New-Object System.Net.Sockets.UdpClient

It works great if a computer is directly connected to a network port on a switch on the same network. However, it would not be so effective if not. For example, if your computer is connected to the network through a VOIP phone, it would be less likely to be woken up by this method.

Leave a Reply

Your email address will not be published. Required fields are marked *