This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Show-TrayNotification

Synopsis

Displays a notification balloon in the system tray.

Syntax

  • Show-TrayNotification [-Message] [-Title] [-IconType]

Description

Show-TrayNotification is used to display a notification balloon and icon in the system tray of the local computer. The notification text is defined using the Title and Message parameters . The icon is defined using the IconType parameter and can be one of the following: Information, Warning, Error, Exclamation, Hand, Shield, Question.

Parameters

  • Message The notification message. This will be displayed in regular type in the notification balloon (under the title, if specified) and can be a maximum of 256 characters. Longer messages will be truncated.
  • Title The title of the notification message. This will be displayed in bold type in the notification balloon and can be a maximum of 64 characters. Longer titles will be truncated.
  • IconType The style of icon to use when displaying the balloon. Valid icon types are Information (default), Warning, Error, Exclamation, Hand, Shield and Question.

Inputs

Show-TrayNotification does not accept pipeline input.

Outputs

Show-TrayNotification does not output any PowerShell objects.

Notes

There are no notes associated with the Show-TrayNotification cmdlet.

Example 1

This command, when placed at the end of a script, will display a notification balloon telling the user that execution of the script has completed. Because the IconType parameter has not been specified, the default Information icon will be used:

C:\PS>Show-TrayNotification -Title "Script Completed" -Message "The script completed successfully"

Example 2

This command, when placed in a script at the appropriate point, will display a notification balloon telling the user that execution of the script has failed. The IconType parameter has been used to specify a Warning icon:

C:\PS>Show-TrayNotification -Title "Script Failed" -Message "The script failed to complete successfully" -IconType Warning

Example 3

This command, when placed in a catch block of a script, will display a notification balloon telling the user that execution of the script has failed and the reason for the failure. The IconType parameter has been used to specify that the Error icon be shown:

C:\PS>Show-TrayNotification -Title "Script Failed" -Message ("The script failed with the following error: {0}" -f $_.exception.message) -IconType Error