Skip to content

Instantly share code, notes, and snippets.

@rolambert
Created March 10, 2022 21:50
Show Gist options
  • Save rolambert/3da1c2082317e38d4a05e89e2309344d to your computer and use it in GitHub Desktop.
Save rolambert/3da1c2082317e38d4a05e89e2309344d to your computer and use it in GitHub Desktop.
Powershell Magic Packet Wake on Lan Snipit
$Mac = "00:11:8c:ee:80:aa"
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray * 16)
$UdpClient = New-Object System.Net.Sockets.UdpClient
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast),7)
$UdpClient.Send($MagicPacket,$MagicPacket.Length)
$UdpClient.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment