Difference between revisions of "Powershell to test connectivity"
From MyWiki
| Line 17: | Line 17: | ||
Combine the two above: | Combine the two above: | ||
<source lang="powershell"> | <source lang="powershell"> | ||
| + | |||
| + | $servers = “dc1″,”dc3″,”sql1″,”wds1″,”ex1″ | ||
| + | Foreach($s in $servers) | ||
| + | |||
| + | { | ||
| + | |||
| + | if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet)) | ||
| + | { | ||
| + | Write-Host "testiing server $s" | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
</source> | </source> | ||
Latest revision as of 09:19, 15 June 2016
Perform action for a list of servers:
$servers = “dc1″,”dc3″,”sql1″,”wds1″,”ex1″ Foreach($s in $servers) {
If no connection do something:
if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet)) {
Combine the two above:
$servers = “dc1″,”dc3″,”sql1″,”wds1″,”ex1″ Foreach($s in $servers) { if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet)) { Write-Host "testiing server $s" } }