What It Does
The script finds the user signed in at the console and shows MESSAGE inside that user's session, using osascript. STYLE Dialog, the default, shows a window titled TITLE with one to three BUTTONS (the first is the default) and waits up to TIMEOUT_SECONDS. The answer says which button was pressed, or that nobody answered and the dialog closed.
STYLE Notification submits a banner to Notification Center and does not wait for a reply or confirm the user saw it. macOS may hide banners that Script Editor is not allowed to show, so use Dialog when the message must be seen. A line break is written \n in MESSAGE.
It shows nothing and ends SKIPPED when nobody is signed in at the console or the user has no desktop session. It changes no setting and starts no app, and it never waits longer than the timeout plus a short margin.
Before You Run It
- MESSAGE is required. Keep it short and say who is asking and why.
- Use Dialog when you need an answer or the message must be seen, and Notification only for a courtesy line.
- Run it with DRY_RUN=true first to see who it would show the message to.
- Read the answer in your RMM. A user who did not answer within the timeout is a reply of its own, so plan for 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 DRY_RUN=true to list every change without making any.
- What it changes: Shows a dialog or notification on the signed-in user's screen.
- Restart: It never restarts the machine.
- Typical run: Up to the timeout (default 60 seconds).
- Example answer: "jsmith pressed Later"
- Tested before listing on macOS 27 (Apple silicon VM) with /bin/bash 3.2, run as root, against its own test cases.
Inputs
Pass an input as an argument (--input-name value), as an environment variable named as listed, which is how most RMMs pass script variables, or change its default in the DEFAULT_ lines near the top of the script. An argument wins over an environment variable, which wins over the default.
- MESSAGE: REQUIRED. What to say, up to 1000 characters.
- TITLE: Window title, up to 100 characters. Default "Message from IT".
- STYLE: Dialog (default) or Notification.
- BUTTONS: Dialog buttons, 1 to 3, comma-separated. The first is the default. Default OK.
- TIMEOUT_SECONDS: Dialog: close after N seconds without an answer. 1-3600, default 60.
Every script also takes DRY_RUN, OUTPUT_FORMAT (Text, Answer, Json or Csv), EXPORT_PATH and RESULT_FIELD, which writes the answer to an RMM custom field, unless the list above words one differently.
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.