Skip to content
Menu

Tell the User Something - Show a Notification

Shows a Windows toast to the signed-in user with a title, a message and an optional Open button. If toasts are off it falls back to msg.exe in their session.

Tell the user something - show a notification is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Tell the user something - show a notification. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, a user signed in at the console
Changes thingsChanges what it runs on

What It Does

The script puts a message on the signed-in user's screen. It runs from SYSTEM and shows the notification in the session of the user signed in at the console, using the Windows PowerShell notification identity. It shows a Windows notification (toast) with Title and Message, adds an Open button when ButtonUrl is set, and with Urgency reminder keeps the notification on screen until the user dismisses it.

If notifications are switched off for that user, or the toast fails, it shows the same text with msg.exe in the user's session instead. It waits for the notification step to return, with a 60-second timeout, but never waits for a click or dismissal. The answer says the notification was shown. It cannot tell whether the user read it, and with Do Not Disturb or Focus Assist on, Windows may only put it in the Action Center. Running it twice shows it twice.

Nobody signed in is SKIPPED. Title and Message must each use printable ASCII and be at most 300 characters. ButtonUrl must use the HTTPS or HTTP scheme and be no more than 300 characters without spaces. Do not put secrets in a message, because it is written to disk for a moment and shown on screen.

Before You Run It

  • Keep the title and message short. Each allows up to 300 printable ASCII characters.
  • Do not put passwords or other secrets in the message. It is shown on screen and written to disk for a moment.
  • Use Urgency reminder only when the message must be seen, such as a required restart.
  • Use DryRun=true to list what would be shown without showing it.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Shows a notification on the signed-in user's screen (a toast, or msg.exe if toasts are off).
  • Restart: It never restarts the machine.
  • Typical run: Under 20 seconds.
  • Example answer: "Notification shown to PC01\jsmith as a toast; shown, not confirmed read."
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • Title: Bold first line of the notification. Plain ASCII, 1 to 300 characters. Default "Message from IT".
  • Message: The text of the notification. Plain ASCII, 1 to 300 characters. Required.
  • ButtonUrl: Optional HTTPS or HTTP web address (up to 300 characters). Adds an Open button to the notification. Default empty: no button.
  • Urgency: normal (default): a normal toast that goes to the Action Center after a few seconds. reminder: stays on screen until the user dismisses it.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

new-user-notification.ps1 · 874 lines · 44.8 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.