With Powershell, you can leverage nearly all features available for .NET applications. Sometimes you must have noticed a popup in the right corner that pops up and it contains icons associated with it. Such notification can be useful if your script is performing some task with your account logged in to the host.
You can see the video here with live demonstration:
Script:
Output:
You may notice a popup something like below. It appears for 5 seconds and disappear. We have added this logic due to reason that we don't have further need to have icon. If you remove the part of script that dispose the variable, the icon will appear forever and it will only go unless the system is rebooted or re-logged in.
You can see the video here with live demonstration:
Script:
#--Declaring the function that takes care of balloon popup --# function Show-BaloonPopup([String]$Title, [String]$Message , [int]$Delay=5 ) { Add-Type -AssemblyName System.Windows.Forms $script:balloon = New-Object System.Windows.Forms.NotifyIcon $Icon = 'Info' $balloon.Icon=[System.Drawing.Icon]::ExtractAssociatedIcon("C:\bin\Apps\Powershell\ico.ico") $balloon.BalloonTipIcon = $Icon $balloon.BalloonTipText = $Message $balloon.BalloonTipTitle = $Title $balloon.Visible = $true $balloon.ShowBalloonTip($Delay*1000) Start-Sleep -s $Delay $balloon.Dispose() } #--Calling the function with appropriate parameters --# Show-BaloonPopup "My Title" "This is the message. You operation has been completed." 5
Output:
You may notice a popup something like below. It appears for 5 seconds and disappear. We have added this logic due to reason that we don't have further need to have icon. If you remove the part of script that dispose the variable, the icon will appear forever and it will only go unless the system is rebooted or re-logged in.
Hope, it was east to implement. Please post comments if you have any difficulty implementing it.
Thanks for reading this article.
only admins can use this function!!!!!
ReplyDeleteAwesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! ลูกโป่งเชียงใหม่
ReplyDeleteI got here much interesting stuff. The post is great! Thanks for sharing it! Especialista en Microsoft Dynamics 365 Business Central con experiencia en NAV
ReplyDeleteI love the way you write and share your niche! Very interesting and different! Keep it coming!
ReplyDeleteSharePoint ticketing system