Having PowerShell talk to you is actually useful!

PowerShell can talk to you.

My favorite use for it, is when I have a script that’s going to run a long time, say 10-20 minutes.
We all KNOW that we’re not going to sit there and watch the output!

Having PowerShell talk when some condition comes up can be really useful if you’ve relegated the window to the background and are doing something else like reading email.

Doing it was super easy.

ADD-TYPE -AssemblyName System.Speech
$speak = new-object System.Speech.Synthesis.SpeechSynthesizer
$speak.speakAsync("Hello from powershell!") > null



#Example use in real world code..

#Loop through 1000 users
foreach ($userId in $massiveListOfUsers)
{
    $result = Check-user -id $userId
    if ($result -eq $false)
    {
         write-host "OH NO THIS USER IS MISSING"
         write-host $userId
         $speak.speakAsync("Can't find $($userId.FirstName) $($userId.LastName)") > $null
    }
}

Shoutout to Michael Blumenthal for suggesting this!

Leave a Reply