Guest User

Untitled

a guest
Jul 6th, 2018
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param (\\[String\\]$MACAddrString = $(throw 'No MAC addressed passed, please pass as xx:xx:xx:xx:xx:xx'))
  2.  $MACAddr = $macAddrString.split(':') | %\\{ \\[byte\\]('0x' + $_) \\}
  3.  if ($MACAddr.Length -ne 6)
  4.  \\{
  5.      throw 'MAC address must be format xx:xx:xx:xx:xx:xx'
  6.  \\}
  7.  $UDPclient = new-Object System.Net.Sockets.UdpClient
  8.  $UDPclient.Connect((\\[System.Net.IPAddress\\]::Broadcast),4000)
  9.  $packet = \\[byte\\[\\]\\](,0xFF * 6)
  10.  $packet += $MACAddr * 16
  11.  \\[void\\] $UDPclient.Send($packet, $packet.Length)
  12.  write "Wake-On-Lan magic packet sent to $MACAddrString, length $($packet.Length)"
RAW Paste Data