Posted: . At: 9:01 AM. This was 2 years ago. Post ID: 16550
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Some very nice Powershell tricks for Windows. How to create a notification window on the desktop.


This one-liner will create a notification window that will pop up. This could be very useful in a Powershell script.

PS C:\Users\Intel i5> powershell -WindowStyle hidden -Command "& {[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Critical system error! Contact technical support immediately. Call 1-800-197-123 for prompt technical support.', 'WARNING')}"

Create a notification bubble that comes out of the System tray.

PS C:\Users\Intel i5> $notify = new-object system.windows.forms.notifyicon
PS C:\Users\Intel i5> $notify.icon = [System.Drawing.SystemIcons]::Information
PS C:\Users\Intel i5> $notify.visible = $true
PS C:\Users\Intel i5> $notify.showballoontip(10,'WARNING','Automatically logoff after 1 hour of inactivity,[system.windows.forms.tooltipicon]::None)
PS C:\Users\Intel i5> $notify.showballoontip(10,'WARNING','Critical system error! Contact technical support immediately. Call 1-800-197-123 for prompt technical support.',[system.windows.forms.tooltipicon]::None)
A notification bubble created with Powershell.
A notification bubble created with Powershell.

The screenshot above shows what this looks like, this is very nice. Would be a great way to get a user`s attention when a script reaches a certain point.

To display a notification pop up on a Linux machine, use this one-liner. This is very easy to use.

jason@jason-Lenovo-H50-55:~$ notify-send "Critical system error! Contact technical support immediately. Call 1-800-197-123 for prompt technical support." -i /usr/share/icons/gnome/32x32/emblems/emblem-urgent.png

Another very useful thing to use in a script is to notify the user when the script has done something. The above example is the best way to do this.


Leave a Comment

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