|
function Ping_Test { PROCESS {
$ping = $false
$results = Get-WmiObject -query `
"SELECT * FROM Win32_PingStatus WHERE Address = '$_'"
$RT = $results.ResponseTime
$TTL = $results.ResponseTimeToLive
foreach ($result in $results) {
if ($results.StatusCode -eq 0) {
if ($TTL -ge 98 -and $TTL -le 128)
{Write-Host "`n$_ Response Time=$RT ms, TTL=$TTL,It is a Windows host." -ForegroundColor Green }
else
{Write-Host "`n$_ Response Time=$RT ms, TTL=$TTL, It is NOT a Windows host." -ForegroundColor Blue}
}
else {
Write-Host "`n$_ Ping failed!" -ForegroundColor Red
}
}
}
}
cls
Get-Content c:\IP.txt | Ping_Test
|
|
|