Send WOL (wake on LAN) with powershell

This powershell function is not mine, but I kept it as I found it useful from time to time.

function Send-WOL
    Send a WOL packet to a broadcast address
   The MAC address of the device that need to wake up
   The IP address where the WOL packet will be sent to
   Send-WOL -mac 00:11:32:21:2D:11 -ip 
$broadcast = [Net.IPAddress]::Parse($ip)
$target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)}
$packet = (,[byte]255 * 6) + ($target * 16)
$UDPclient = new-Object System.Net.Sockets.UdpClient
[void]$UDPclient.Send($packet, 102) 

Leave a Reply