Win10 专业版
Win10 如何用powershell写个WOL开机脚本
1.脚本内容
$mac = 'b1-10-18-52-11-12'
$macBytes = $mac -split '-' | ForEach-Object { [byte]('0x' + $_) }
$broadcastAddress = [byte[]](1..6 | ForEach-Object { 0xFF })
$magicPacket = $broadcastAddress + ($macBytes * 16)
$udpClient = New-Object System.Net.Sockets.UdpClient
$udpClient.Connect(([System.Net.IPAddress]::Broadcast), 9)
$udpClient.Send($magicPacket, $magicPacket.Length)
2.将b1-10-18-52-11-12’替换为目标主机的MAC地址。
3.将脚本保存为wol.ps1文件,保存在您喜欢的位置。
4.然后,您可以在命令提示符中运行PowerShell脚本来发送唤醒包:
powershell.exe -ExecutionPolicy Bypass -File C:\path\to\wol.ps1
5.请确保将C:\path\to\wol.ps1替换为您实际保存脚本的路径