Skip to main content

Toast Notification

Overview

This script is to create and manage toast notifications with customizable options, including images, buttons, and scenarios for different use cases. It is Ninja implementation of the agnostic script Invoke-ToastNotification.ps1.

Update Notice: 2025-07-22

  • A script can be triggered via a button click within the notification.
  • The dismiss button is optional and can be excluded.
  • Notifications can be shown with or without buttons.
  • New Parameters:
    • RunScriptButtonText
    • ScriptPath
    • ScriptContext
    • HideDismissButton
  • Parameters Removed:
    • SnoozeButton (Was unnecessary)
    • LearnMoreButton (Removed to adjust new parameters, setting the LearnMoreUrl will enable the button)

Sample Run

Image1

Variables

IDNameValue
1NotificationTypeGeneric
2RebootButton1
3RunScriptButtonTextReboot at 8
4ScriptPathC:\ProgramData_Automation\Script\Rebootat8\Rebootat8.ps1
5ScriptContextSystem
6LearnMoreUrlhttps://en.wikipedia.org/wiki/Hamster
7HideDismissButton1
8TitleTextHamster Overload Detected!
9AttributionTextwww.provaltech.com
10BodyText1The tiny hamster powering your computer is absolutely exhausted and needs a magical nap to keep things running smoothly! Please be kind, click 'Reboot Now' to give it a break, or choose 'Reboot at 8' to let it rest later tonight.
11BodyText2If you ignore this plea, the hamster will take matters into its own tiny paws and force a nap at 8 PM anyway. Let's not push our luck with a tired rodent on a wheel!.
12LogoImageC:\ProgramData_Automation\Script\Rebootat8\magicalHamster.png
13HeroImageC:\ProgramData_Automation\Script\Rebootat8\runningHamster.png
14NotificationAppNameWheelWorks
15RepeatOnce
16MaxOccurrences1

Outcome

Notification

Image1

Scheduled Task

Image2

Reboot at 8

Image2

Affected Areas on Prompt Based on Example Variables

Image2

Dependencies

Parameters

NameExampleAccepted ValuesRequiredDefaultTypeDescription
NotificationTypeGeneric
  • Generic
  • PendingRebootUptime
  • PendingRebootCheck
  • ADPasswordExpiration
Yes-Drop-DownThe type of notification to send. The accepted values for NotificationType are generic, PendingRebootUptime, PendingRebootCheck, and ADPasswordExpiration. It is a mandatory variable.
  • Generic: Enables a static, generic toast notification.
  • PendingRebootUptime: Displays a toast notification reminding users to restart their system after exceeding the maximum uptime.
  • PendingRebootCheck: Displays a toast notification when a pending reboot is detected through the system registry or WMI.
  • ADPasswordExpiration: Sends a toast notification to users when their Active Directory password is nearing expiration.
RebootButton-true/false (checkbox)NoCheckBoxSelect RebootButton to enable the Reboot button in the notification. Unselecting the variable will disable it. RebootButton is available for Generic, PendingRebootUptime, and PendingRebootCheck notification types.
RunScriptButtonTextUpdate NowAny stringNoString/TextSet the string in this variable to add a custom button with the name set in this variable to run a specified PowerShell script when clicked.
ScriptPathC:\Scripts\update.ps1Valid .ps1 file pathNoString/Textscript (.ps1) to execute when the custom button is clicked. This must be a valid path ending in .ps1. Setting this variable is mandatory if RunScriptButtonText is set.
ScriptContextSystem
  • User
  • System
No-Drop-DownThe context in which the script runs. This can be 'User' or 'System'.
LearnMoreUrlhttps://example.com/helpValid URLNoString/TextURL to learn more about the notification. If this variable is set, a 'Learn More' button will be added to the notification.
HideDismissButton-true/false (checkbox)NoCheckBoxSelect to remove the Dismiss button from the notification. Dismiss button is added to the notification by default.
DismissButtonTextCloseAny stringNoString/TextSet the string in the DismissButtonText variable to customize the dismiss button's text. Leave it blank to return to the default value, Dismiss.
TitleTextSystem Update RequiredAny stringYesString/TextSets the title of the notification in the TitleText variable. It is mandatory to set this variable.
AttributionTextIT DepartmentAny stringNoOrganization nameString/TextSets the attribution text in the AttributionText variable. It can be a company name or website, for authenticity. If not set, it defaults to the organization name.
BodyText1Your system requires an updateAny string (avoid double quotes)YesString/TextBodyText1 stores the main text content of the notification body. It is a mandatory variable. Avoid using double quotes in the text.
BodyText2Please save your work before continuingAny string (avoid double quotes)NoString/TextBodyText2 stores the secondary text content of the notification body. Avoid using double quotes in the text.
LogoImageC:\Images\logo.pngURL or local pathNoDefault logoString/TextLogoImage stores the URL or local path for the logo image in the notification. Leave it blank to generate the notification with the default logo. For best experience, keep the ratio 1:1 (Horizontal:Vertical) ; Example - 300px:300px (Horizontal:Vertical)
HeroImageC:\Images\hero.jpgURL or local pathNoDefault imageString/TextHeroImage stores the URL or local path for the primary image in the notification. Leave it blank to generate the notification with the default image. For best experience, keep the ratio 2:1 (Horizontal:Vertical); Example - 600px:300px (Horizontal:Vertical)
Deadline2025-12-31 23:59:59yyyy-MM-dd HH:mm:ss formatNoString/TextSets the deadline for the notification. Format: yyyy-MM-dd HH:mm:ss.Note that RunScriptButton and Deadline cannot be enabled at the same time. Additionally, enabling RunScriptButton will automatically disable Deadline.
MaxUptimeDays30Positive integerNo30IntegerDefines the maximum uptime (in days) for the PendingRebootUptime NotificationType parameter. Default is 30 days.
ADPasswordExpirationDays7Positive integerNo7IntegerNumber of days before password expiration when reminders should start. It is available for the ADPasswordExpiration NotificationType parameter. Default is 7 days.
RepeatDailyOnce, Hourly, XXMinutes, XXHours, Daily, XXDaysNoOnceString/TextSpecifies how frequently the notification should repeat. Options: Once, Hourly, XXMinutes, XXHours, Daily, XXDays. Default is Once.
NotificationAppNameCompany IT ToolAny stringNoWindows PowerShellString/TextSpecifies the name of the application that will display the notification.
MaxOccurrences5Positive integerNoIntegerSpecifies the maximum number of notifications to send before the scheduled task is automatically removed. This works in conjunction with the Repeat parameter, except when Repeat is set to Once.

Note: Variables marked as "Required: Yes" are mandatory and must be configured. Variables with checkbox types accept boolean values (true/false). For drop-down types, only the specified accepted values are valid.

Automation Setup/Import

Automation Configuration

Output

  • Activity Details
  • Custom Field