Powershell: ping: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Created page with 'Skript näitab kas pingitav aadress on edukas või mitte $Srvname = Read-Host "SISESTA HOSTI NIMI VÕI IP AADRESS" $ping = new-object System.Net.NetworkInformation.Ping $shell …' |
No edit summary |
||
Line 1: | Line 1: | ||
$ | $ping = "C:\Users\Marek\Desktop\ping.csv" | ||
$csv = Import-CSV $ping | |||
$smtpServer = "" | |||
$ | foreach($item in $csv){ | ||
} | $server = $item.HostName | ||
$ip = $item.IpAddress | |||
{ | |||
$ | $ping = new-object System.Net.NetworkInformation.Ping | ||
$rslt = $ping.send($ip) | |||
#Write-host $rslt | |||
if ($rslt.status.tostring() –eq "Success") { | |||
write-host ping tootas $server with $ip -ForegroundColor Green | |||
# write-host $rslt.status.tostring() | |||
} | |||
else { | |||
write-host ping eba6nnestus $server with $ip -ForegroundColor Red | |||
} | } | ||
$ping = $null |
Revision as of 19:26, 31 May 2012
$ping = "C:\Users\Marek\Desktop\ping.csv" $csv = Import-CSV $ping $smtpServer = ""
foreach($item in $csv){
$server = $item.HostName $ip = $item.IpAddress
$ping = new-object System.Net.NetworkInformation.Ping $rslt = $ping.send($ip) #Write-host $rslt if ($rslt.status.tostring() –eq "Success") { write-host ping tootas $server with $ip -ForegroundColor Green # write-host $rslt.status.tostring() } else { write-host ping eba6nnestus $server with $ip -ForegroundColor Red
} $ping = $null