Wake-on-LAN using PowerShell

Wake-on-LAN and the Magic Packet

The format of a Wake-on-LAN (WOL) magic packet is defined as a byte array with 6 bytes of value 255 (0xFF) and 16 repetitions of the target machine’s 48-bit (6-byte) MAC address. (See Wikipedia article)

Wake-on-LAN works by broadcasting the magic packet to all network devices in a network. The network device that has a matching MAC address is instructed to be woken up, should they be configured to handle Wake-on-LAN requests.

$Mac = "84:a9:3e:80:28:62"
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray  * 16)
$UdpClient = New-Object System.Net.Sockets.UdpClient

Just replace the $Mac.

To find out the MAC Address, you can try using arp -a in a PowerShell or Command prompt. Alternatively you just use DHCPMGMT.msc, there you can find the MAC Address too.