pátek 28. srpna 2009

Wake On LAN

function wakeComputer([String]$macAddress)
{
    $mac = [byte[]]($macAddress.split(':') |% {[int]"0x$_"}) 
 
    $UDPclient = new-Object System.Net.Sockets.UdpClient
    $UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)
    $packet = [byte[]](,0xFF * 102)
    6..101 |% { $packet[$_] = $mac[($_%6)]}
    $sent = $UDPclient.Send($packet, $packet.Length)
    "$sent bytes sent. The computer $macAddress may be initializing."
}
zdoj: http://blogs.technet.com/migreene/archive/2009/04/01/3221273.aspx

Žádné komentáře: