Today With PowerShell – Tuesday 17th May, 2016

So I got pretty much everything wrong in my last post.

My example PowerShell written based on a snippet I had used at work plus an incomplete understanding of the (limited) built in help for Test-Connection. I managed to get my True and False mixed up too.

As my penance here’s a function that actually does what I said the previous snippet would do:

Function Wait-ForHost {
param ($hostname)
do {
$pingback = Test-Connection -count 1 -ComputerName $hostname -Quiet
Start-Sleep 15
until ($pingback -eq $True)
Write-Host "$hostname is alive!"

I’ll try harder next time.

This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s