ps1脚本发送magic数据包,唤醒网络中电脑

【リスト11:WakeOnLan.ps1】
1 param($MacAddress) 
2 [byte[]] $MagicPacket = 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
3 $MagicPacket += (($MacAddress.split('-') | foreach {[byte] 
('0x' + $_)}) * 16)
4 $UdpClient = New-Object System.Net.Sockets.UdpClient
5 $UdpClient.Connect(([System.Net.IPAddress]::Broadcast) ,9)
6 $UdpClient.Send($MagicPacket,$MagicPacket.length)

你可能感兴趣的:(ps1脚本发送magic数据包,唤醒网络中电脑)