Speak to me: PowerShell tells you if a host is up or not (Test-Connection)

Execute the following two-liners to cause PowerShell saying “Command completed successfully”.

$words = New-Object -ComObject SAPI.SpVoice
$words.speak("Command completed successfully")

So I came up with an idea. PowerShell shall tell me if a host is up or not. All I need is a simple if statement and Test-Connection.

Copy the following code in your PowerShell Session and enter a hostname or IP Address (for example: sid-500.com):

$IPorName=Read-Host "IP Address or Name of Remote Host?"
$up="$IPorName is up"
$words=New-Object -ComObject SAPI.SpVoice
If (Test-Connection $IPorName -Quiet -Count 1)
{Write-Host "Host is down"}

To find all voices type

$words.GetVoices() | Foreach-Object {$_.getdescription()}


I wish all my readers a nice weekend!

See also my articles about Test-Connection and Test-NetConnection: The modern version of ping: Test-Connection and PowerShell: Playing with Test-NetConnection (ping, tracert, TCP Ports …)

Categories: PowerShell

Tagged as: ,

2 replies »

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.