понедельник, 9 октября 2017 г.

PingTest.PS1

PingTest.PS1
$servers = "dc1","dc3","sql1","wds1","ex1"
Foreach($s in $servers)
{
  if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))
  {
   "Problem connecting to $s"
   "Flushing DNS"
   ipconfig /flushdns | out-null
   "Registering DNS"
   ipconfig /registerdns | out-null
  "doing a NSLookup for $s"
   nslookup $s
   "Re-pinging $s"
     if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))
      {"Problem still exists in connecting to $s"}
       ELSE {"Resolved problem connecting to $s"} #end if
   } # end if
} # end foreach



https://blogs.technet.microsoft.com/heyscriptingguy/2012/02/24/use-powershell-to-test-connectivity-on-remote-servers/

Комментариев нет:

Отправить комментарий