From time to time I find myself needing a notification tool. Normally a simple show messagebox will suffice, however the trouble with that is that is blocking until someone clicks that OK button. I have seen workarounds that uses wscript and other things, however that is just meh.
There is a function in my general purpose repro on BitBucket that is called Show-Message. Here is the function:
The “good” thing about this is that it also works on Windows Server 2016 with the GUI experience, however who is using a GUI on a server nowadays? Everybody should be using Nano or Server Core, right?
In addition the function will fallback to a regular good old MessageBox if the Windows.UI.Notification namespace is not available. Please note that in those scenarios, the function will block execution until the OK button is clicked.
Here is how a notification looks like:
You can also control for how long the notification should be shown to the user with the DisplayDuration parameter.
If you simply want to display a regular MessageBox, just run Show-Message -Message "Test message" and it will show you a message box:
That is it.