Sep 162015
 

Si vous avez une BBox qui d?conne comme la mienne, vous ne savez plus où se trouve quelle VM/PC/T?l?phone/bidule.. d’un point de vue IP. Ce petit script fait un inventaire assez sympa. (attention, gourmand en ressources )

Adaptez les champs en gras selon vos besoins 🙂

$MASK='10.254.0.'
$myJobs=for( $i=1;$i -le 254 ; $i++){ 
  $ip=''+$MASK+$i
  Start-Job? -ArgumentList $ip -ScriptBlock { param ($ip)
    if ( test-connection $ip -Quiet -Count 2 ) {
      try    { $hostname=[System.Net.Dns]::gethostentry($ip).Hostname }
      catch { $hostname='Unknown' }

      Finally{ New-Object PSObject -Property @{ IP = $IP ; HostName = $Hostname } }
    }
  }
}
$myJobs | wait-job | out-null
$myJobs | foreach { $_ | receive-job -keep | select IP, Hostname } | tee -variable inventaire | ft -autosize

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)