Sending Magic Packet

by Feb 24, 2011

You can also send a "magic packet" with the machines MAC address if you'd like to wake up a machine,. Here is how to send such a packet– just make sure you adjust $mac to the MAC address your machine is using.

$mac = [byte[]](0x00, 0x11, 0x85, 0x83, 0xad, 0x3b)
$UDPclient = new-Object System.Net.Sockets.UdpClient
$UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)
$packet = [byte[]](,0xFF * 102)
6..101 |% { $packet[$_] = $mac[($_%6)]}
"Send: "
$packet
$UDPclient.Send($packet, $packet.Length)

Twitter This Tip!
ReTweet this Tip!