Multitasking is distracting. Like most IT people, I start one job, then get thrown 10 more things that “need to be completed ASAP”. Some of them get done quickly, some take some time to query, search, etc. And if you are working on remote systems, just needs to run for a while.
I created several functions to notify me of when they finish running. Two of them display something to the screen and the third will actually talk to me using my computer speakers.
The first one pops up a message box that forces me to click on it, the second one will just display a notification balloon that shows in the notification area and the third speaks to me using my computer speakers.
Example using Pop-Up box.
foreach ($thing in $list) {
# Do Something over and over
}
Show-MsgBox -Prompt "My long running loop has finished." -Title "Completed" -BoxType OKOnly -ShowOnTopSo the last line tells me that the loop has finished. It will stay on my screen until I click on it. I use that to make sure that I see the message if I walk away from my desk and come back to it.
Example using a notification balloon
The next example shows a notification balloon with the same time of information, but once the notification balloon appears, it will disappear after a while.
foreach ($thing in $list) {
# Do Something over and over
}
New-IgBalloon -Text "First loop done." -Title "Part 1"
foreach ($thing in $anotherlist) {
# Do Something over and over
}
New-IgBalloon -Text "Second loop done." -Title "Part 2"I like to use the notification balloons to give me status updates for phases of a long running script of job.
The final notification that I use actually uses computer speech to tell me something has completed. To be honest, I do not use this one often because I don’t want to disturb people around me. What I really use this one for is to mess with others more than anything else.
Example using Out-Speak
foreach ($thing in $list) {
# Do Something over and over
}
"The job has completed" | Out-SpeakTells me the job has completed. But how I really use it is to leave a recording on my voice mail message.
for ($i = 1; $i -lt 4; $i++) {
"The voice mail box has not been setup for this phone number. Please call back later." | Out-Speak -Type Female
Start-Sleep 3
}So start using notifications to improve your ability to multitask.
You find the IgNotifications module on the APUG PowerShell Repository. If you haven’t added it, see our APUG PS Repository post that shows you how to load that repository.
