powershell远程唤醒系统


从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 <<—-成功

 

相关内容

    暂无相关文章