Powershell: ping

From ICO wiki
Revision as of 19:29, 31 May 2012 by Mlepla (talk | contribs)
Jump to navigationJump to search

Name: ping1.ps1

  1. Author: Marek Lepla
  2. Date: 31.05.2012
  3. Comment: See skript pingib kõiki web-i aadresse, mis on kirjutatud CSV faili.


$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