Skip to content

Instantly share code, notes, and snippets.

@sub314xxl
Created December 9, 2017 15:42
Show Gist options
  • Save sub314xxl/e542930a2a4ac979fef794f0725f8341 to your computer and use it in GitHub Desktop.
Save sub314xxl/e542930a2a4ac979fef794f0725f8341 to your computer and use it in GitHub Desktop.
$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment