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: