- function Send-WOL
- {
- <#
- .SYNOPSIS
- Send a WOL packet to a broadcast address
- .PARAMETER mac
- The MAC address of the device that need to wake up
- .PARAMETER ip
- The IP address where the WOL packet will be sent to
- .EXAMPLE
- Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255
- #>
- [CmdletBinding()]
- param(
- [Parameter(Mandatory=$True,Position=1)]
- [string]$mac,
- [string]$ip="255.255.255.255",
- [int]$port=9
- )
- $broadcast = [Net.IPAddress]::Parse($ip)
- $mac=(($mac.replace(":","")).replace("-","")).replace(".","")
- $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
- $UDPclient.Connect($broadcast,$port)
- [void]$UDPclient.Send($packet, 102)
- }
Send-WakeOnLANpacket
Posted by Anonymous on Fri 29th Sep 2017 15:53
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.