The idea was to ping each and every machine in 192.168.0.xxx range, disconnect the PC, ping the range again, get the difference.
A cool way to do it, I guess, involves PowerShell, but I don't know how to use it. I know F# a bit :)
Here is the code:
open System open System.Net open System.Net.NetworkInformation let p = new Ping() let isOnline n = p.Send(new IPAddress([|192uy; 168uy; 0uy; (byte)n|]), 100).Status = IPStatus.Success let div2 n = n % 2 = 0 let online1 = [2..254] |> Seq.filter isOnline |> Seq.toArray // At this moment I physically disconnected the PC I needed to discover let online2 = [2..254] |> Seq.filter isOnline |> Seq.toArray // here it is :) let pc = Set.difference (Set.ofArray online1) (Set.ofArray online2) // it's 75 // connected the PC, and ... isOnline 75 // Hurra, it's online
Luckily, DCHP server was up :) and the PC got its IP back when connected.
No comments:
Post a Comment