BurntToast PowerShell Module

repository·main·Indexed 23 days ago

https://github.com/windos/burnttoast

A PowerShell module for displaying Windows Toast Notifications on Windows 10 and Windows Server 2019 or newer. It provides functions to create notification bindings, audio objects, and interactive actions including buttons, input controls, and progress bars. The module utilizes the Microsoft.Toolkit.Uwp.Notifications library and includes utilities like Get-BTHeader and Get-BTHistory to manage notifications in the Windows Action Center.

Tokens
11K
Snippets
34
Records
60
Agent score
79%

What's inside BurntToast

  1. Configure Determinate vs Indeterminate progress bars

    main

    You can choose between two modes for the progress bar:

    1. Determinate (Percentage-based): Use the -Value parameter with a Double between 0 and 1. You can optionally use -ValueDisplay to show custom text instead of the percentage.

      New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete'
    2. Indeterminate (Animation-based): Use the -Indeterminate switch. This is useful when the exact completion time or percentage is unknown.

      New-BTProgressBar -Status 'Copying files' -Indeterminate
  2. Create a Windows shortcut with New-BTShortcut

    main

    To ensure toast notifications display your custom app name and icon (registered via New-BTAppId), you must launch PowerShell or a compatible host from a shortcut that has the AppUserModelID property set. New-BTShortcut automates the creation of this shortcut.

    Important: After creating the shortcut, you must launch PowerShell exclusively via this shortcut to guarantee Windows uses your custom branding for actionable toast notifications.

    New-BTShortcut -AppId "Acme.MyApp" -DisplayName "My App PowerShell" -IconPath "C:\Path\To\MyIcon.ico"
  3. Include a progress bar in a toast binding

    main

    You can include a progress bar in your notification by creating a progress bar object with New-BTProgressBar and passing it to the -Children parameter of New-BTBinding.

    $progress = New-BTProgressBar -Title 'Updating' -Status 'Running' -Value 0.4
    $binding = New-BTBinding -Children $progress
  4. Create a single column layout with New-BTColumn

    main

    You can use New-BTColumn to wrap individual elements for structured layouts. This is useful when passing a column to New-BTBinding.

    # Example 2: Wrapping a single text element in a column
    $label = New-BTText -Text 'Now Playing'
    $col = New-BTColumn -Children $label
    New-BTBinding -Children $label -Column $col
  5. Use system-handled Snooze and Dismiss actions

    main

    To add standard system-handled Snooze and Dismiss buttons to a notification, use the -SnoozeAndDismiss switch. Note that this parameter set is mutually exclusive with custom actions like buttons or inputs.

    New-BTAction -SnoozeAndDismiss