Manito Networks

View Original

Alert Notifications in Windows with Powershell

Need help with implementation or an upcoming project? We offer professional services at reasonable rates to help you with your next network rollout, security audit, architecture design, and more. Click here to find out more.

We've already covered using the native msg shell command to create notifications, but the basic msg notification is crude compared to what we can do in Powershell. It also reveals who sent the message and when, which looks suspicious. With Powershell we can start to script alerts and customize them further. Powershell.org has a great article about using just a couple lines to generate a dynamic alert using the old VBscript Popup method. Here's an example of my notification usage with their method:

$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("Operation Completed",0,"System Message",64+1)

The commands are a bit more complex than the one-liner msg method, but we can customize the alert's title, contents, what buttons are shown, and get a status code when the user clicks those buttons. Microsoft's documentation of the popup method lays out the customization options.

Here's the output from my example above:

Powershell Popup Notification

Compare that with what we saw in the article using msg to generate notifications:

Msg notification

Powershell's output looks much cleaner and official than the output of the msg command. Either way you go, it's easy to create alert notifications in Windows.