Hviidnet.com
9Jul/080

Powershell: Scanning a network for alive hosts

This is a way to scan a network for ip's and return if hosts are alive or dead.

$i =1
$Ip = "10.0.0."
$ipsamling = @()
Write-Host "IP Address"
Write-Host "----------------------------------------"
do { $Ip4th = $Ip + $i
$Pingy = get-WmiObject Win32_PingStatus -f "Address='$Ip4th'"
if($Pingy.StatusCode -eq 0) {
"{0,0} {1,5} {2,5}" -f
$Pingy.Address, $Pingy.StatusCode," ON NETWORK"
$ipsamling += $Pingy.Address
}
else
{"{0,0} {1,5} {2,5}" -f $Pingy.Address, $Pingy.StatusCode, " xxxxxxxxx"
}
$i++
}
until ($i -eq 20)

echo "Kontakt til:"
echo $ipsamling

Related posts:

  1. Nice powershell snippets to do diffrent stuff
  2. Exclude VMware Virtual Adapters from Network Awareness
  3. Powershell: Create a function
  4. Powershell: A simple RSS Reader
  5. VMWARE on ubuntu 6.06 LTS Network subnet
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.