Wake on LAN
Je recherchais un script en Powershell pour démarrer les PC à distance. J’ai trouvé celui-ci sur le technet. A voir si on peut lui indiquer une IP plutôt que la MAC.
Sinon, j’ai un autre script dans les cartons qui doit faire ça. A voir prochainement.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Script to wake up a computer. # # v1.0 # usage: # .\wakeonlan.ps1 -mac 00:1D:92:51:4C:41 param( [string]$mac = 'FF:00:AA:B2:99:F5' #address of the network card (MAC address) ) #checks the syntax of MAC address if (!($mac -like "*:*:*:*:*:*") -or ($mac -like "*-*-*-*-*-*")){ write-error "mac address not in correct format" break } #build magic package http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet $string=@($mac.split(":""-") | foreach {$_.insert(0,"0x")}) $target = [byte[]]($string[0], $string[1], $string[2], $string[3], $string[4], $string[5]) # The magic packet is a broadcast frame containing anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal) $packet = [byte[]](,0xFF * 102) # followed by sixteen repetitions of the target computer's 48-bit MAC address, for a total of 102 bytes. 6..101 |% { $packet[$_] = $target[($_%6)]} # .NET framework lib para sockets $UDPclient = new-Object System.Net.Sockets.UdpClient $UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000) $UDPclient.Send($packet, $packet.Length) | out-null |


