community.windows.win_msg module – Sends a message to logged in users on Windows hosts
Note
This module is part of the community.windows collection (version 1.13.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_msg
.
Synopsis
Wraps the msg.exe command in order to send messages to Windows hosts.
Parameters
Parameter |
Comments |
---|---|
How long to wait for receiver to acknowledge message, in seconds. Default: |
|
The text of the message to be displayed. The message must be less than 256 characters. Default: |
|
Who to send the message to. Can be a username, sessionname or sessionid. Default: |
|
Whether to wait for users to respond. Module will only wait for the number of seconds specified in display_seconds or 10 seconds if not specified. However, if wait is Choices:
|
Notes
Note
This module must run on a windows host, so ensure your play targets windows hosts, or delegates to a windows host.
Messages are only sent to the local host where the module is run.
The module does not support sending to users listed in a file.
Setting wait to
yes
can result in long run times on systems with many logged in users.
See Also
See also
- community.windows.win_say
Text to speech module for Windows to speak messages and optionally play sounds.
- community.windows.win_toast
Sends Toast windows notification to logged in users on Windows 10 or later hosts.
Examples
- name: Warn logged in users of impending upgrade
community.windows.win_msg:
display_seconds: 60
msg: Automated upgrade about to start. Please save your work and log off before {{ deployment_start_time }}
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Value of display_seconds module parameter. Returned: success Sample: |
|
Test of the message that was sent. Returned: changed Sample: |
|
The return code of the API call. Returned: always Sample: |
|
How long the module took to run on the remote windows host. Returned: success Sample: |
|
local time from windows host when the message was sent. Returned: success Sample: |
|
Value of wait module parameter. Returned: success Sample: |