從MS官方blog上看到一則很實用的指令碼,用來遠程喚醒系統
1、確認你的系統是否支援遠程喚醒
#ethtool etho|grep ‘Wake-on’
Supports Wake-on: pumbag
Wake-on: g
g 表示已啟動
2、編寫指令碼
########################
param($MacAddress)
echo “Wake up $MacAddress Now!”
[byte[]] $MagicPacket = 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
$MagicPacket += ($MacAddress.split(‘-’) | foreach {[byte] (’0x’ + $_)}) * 16
$UdpClient = New-Object System.Net.Sockets.UdpClient
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast) ,9)
$UdpClient.Send($MagicPacket,$MagicPacket.length)
########################
儲存為wakeup.ps1
3、測試
PS D:programmepowershell> ping 192.168.1.188 -n 1;.wakeup.ps1 00-16-11-11-11
-11;ping 192.168.1.188 -n 3
Pinging 192.168.1.188 with 32 bytes of data:
Request timed out. <<—-系統處於掛起的狀態
Ping statistics for 192.168.1.188:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
Wake up 00-16-d3-c6-bd-25 Now!
102
Pinging 192.168.1.188 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.188: bytes=32 time=1ms TTL=64
Reply from 192.168.1.188: bytes=32 time<1ms TTL=64 <<—-成功