How to keep powershell notification in action center

Viewed 5146

I have this powershell script to send a notification which works great, except for the fact that it is not saved in the notification center. It times out, and fades away, but it is not there when you click the notifications button on the right of the taskbar. Is there anything I could add to my script to make it happen? Thanks!

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon 

$objNotifyIcon.Icon = "icoOnline.ico"
$objNotifyIcon.BalloonTipIcon = "None" 
$objNotifyIcon.BalloonTipText = "wzzup this is a title." 
$objNotifyIcon.BalloonTipTitle = "WHATS UPPP THIS IS A PARAGRAPH!"

$objNotifyIcon.Visible = $True 
$objNotifyIcon.ShowBalloonTip(10000)
1 Answers

You can use a while condition to make it last. But again dont make the script hold permanently. Instead you can create a background job for the same.

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
while($True)
{
$objNotifyIcon.Icon = [System.Drawing.SystemIcons]::Information
$objNotifyIcon.BalloonTipIcon = "Info" 
$objNotifyIcon.BalloonTipTitle = "wzzup this is a title." 
$objNotifyIcon.BalloonTipText = "WHATS UPPP THIS IS A PARAGRAPH!"
$objNotifyIcon.Visible = $True 
$objNotifyIcon.ShowBalloonTip(10000)
Start-Sleep 500
}

Hope it helps.

Related