What OS and PowerShell version are you using?
In testing your code on one of my Win10/PSv5x system, in either the ISE/VSCode/consolehost, the messagebox (from your show event) appears whether I click the balloon, or click the arrow to dismiss it. Actually, clicking anywhere on the screen dismisses the balloon on Windows by default, that is not your code, but even that still fires you message box. If you wait for the timer to fire, the balloon of course goes away and the message box appears.
Hovering of the default icon, does nothing, and shouldn’t, since you have no actions to handle hover. Meaning, this ‘hover over the icon it immediately disappears.’, does not happen in the system I tested this on.
As for this…
Settings for my balloon are 'Show Icon and Notifications (alongside the 'Power Shell' label).
… where are you setting this? It not in the code you posted, and looking at all of my PowerShell code I’ve done or collected on this topic, I see no apparent way of getting all that you are after, they way you have explained your use case.
Also, take a look at the BurntToast module to see is that gets you where you need to go. Take a look at is code.
Find-Module -Name '*toast*' | fl -Force
Name : BurntToast
Version : 0.7.0
Type : Module
Description : Module for creating and displaying Toast Notifications on Microsoft Windows 10.
Author : Joshua (Windos) King
CompanyName : Windos
Copyright : (c) 2015 Joshua (Windos) King. All rights reserved.
PublishedDate : 4/1/2019 8:28:18 AM
InstalledDate :
UpdatedDate :
LicenseUri : https://github.com/Windos/BurntToast/blob/master/LICENSE
ProjectUri : https://github.com/Windos/BurntToast
IconUri : https://raw.githubusercontent.com/Windos/BurntToast/master/Media/BurntToast-Logo.png
Tags : {Notifications, Utilities, Windows10, Toast, PSModule}
Includes : {Function, RoleCapability, Command, DscResource, Workflow, Cmdlet}
PowerShellGetFormatVersion :
ReleaseNotes : # 0.7.0
* HEADLINE FEATURE: My People "Shoulder Tap" notifications have been implemented
* You can now specify images on the network via UNC paths. Fix for #56
* We're now properly supporting bindable text, and removing the curly braces more gracefully
* Get a list of all toasts you've sent, which have not been dismissed by the user, using Get-BTHistory
* Remove toasts you've sent, using Remove-BTNotification
* Set expiration times on toasts using the new ExpirationTime parameter on New-BurntToastNotification and
Submit-BTNotification
* Toasts which have expired are removed from the Action Center
* Send toasts directly to the Action Center, and avoid showing them on screen, with the new SuppressPopup
switch on New-BurntToastNotification and Submit-BTNotification
* You can now adjust a toasts timestamp (both past and future) using the CustomTimestamp parameter on
New-BurntToastNotification and New-BTContent
* If not specified, the system uses the time at which the toast was received and this may not accuratly
reflect the intent of the notification
Dependencies : {}
RepositorySourceLocation : https://www.powershellgallery.com/api/v2
Repository : PSGallery
PackageManagementProvider : NuGet
AdditionalMetadata : @{summary=Module for creating and displaying Toast Notifications on Microsoft Windows 10.;
downloadCount=50728; created=4/1/2019 8:28:18 AM -07:00; description=Module for creating and displaying
Toast Notifications on Microsoft Windows 10.; copyright=(c) 2015 Joshua (Windos) King. All rights
reserved.; FileList=BurntToast.nuspec|BurntToast.psd1|BurntToast.psm1|config.json|README.md|Images\BurntToa
st-Logo.png|Images\BurntToast.png|lib\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notificatio
ns.dll|lib\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.xml;
lastUpdated=6/9/2019 1:55:50 AM -07:00; published=4/1/2019 8:28:18 AM -07:00; tags=Notifications Utilities
Windows10 Toast PSModule; releaseNotes=# 0.7.0
* HEADLINE FEATURE: My People "Shoulder Tap" notifications have been implemented
* You can now specify images on the network via UNC paths. Fix for #56
* We're now properly supporting bindable text, and removing the curly braces more gracefully
* Get a list of all toasts you've sent, which have not been dismissed by the user, using Get-BTHistory
* Remove toasts you've sent, using Remove-BTNotification
* Set expiration times on toasts using the new ExpirationTime parameter on New-BurntToastNotification and
Submit-BTNotification
* Toasts which have expired are removed from the Action Center
* Send toasts directly to the Action Center, and avoid showing them on screen, with the new SuppressPopup
switch on New-BurntToastNotification and Submit-BTNotification
* You can now adjust a toasts timestamp (both past and future) using the CustomTimestamp parameter on
New-BurntToastNotification and New-BTContent
* If not specified, the system uses the time at which the toast was received and this may not accuratly
reflect the intent of the notification; Authors=Joshua (Windos) King; ItemType=Module;
PackageManagementProvider=NuGet; versionDownloadCount=13841; updated=2019-06-09T01:55:50Z;
CompanyName=king.geek.nz; developmentDependency=False; NormalizedVersion=0.7.0; PowerShellVersion=5.0;
title=BurntToast; GUID=751a2aeb-a68f-422e-a2ea-376bdd81612a; isLatestVersion=True; Functions=Get-BTHistory
New-BTAction New-BTAppId New-BTAudio New-BTBinding New-BTButton New-BTContent New-BTContextMenuItem
New-BTHeader New-BTImage New-BTInput New-BTProgressBar New-BTSelectionBoxItem New-BTShoulderTapBinding
New-BTShoulderTapImage New-BTShoulderTapPeople New-BTText New-BTVisual New-BurntToastNotification
New-BurntToastShoulderTap Remove-BTNotification Submit-BTNotification Update-BTNotification;
requireLicenseAcceptance=False; isAbsoluteLatestVersion=True; IsPrerelease=false; packageSize=204286;
SourceName=PSGallery}
So, does this …
Unfortunately I don't know powershell so this is kind of a guess.
… mean, you’ve spent no real time learning PowerShell prior to doing this?
If so, please, save yourself the frustration, misconceptions, unnecessary hair-pulling, errors, bad habits, etc., and jump on YouTube, or MSDN channel9 and grow thru the videos for beginning/intermediate/advanced PowerShell, PowerShell GUI, PowerShell using .Net, etc., to get a better/firmer grounding on it.