community.windows.win_msg (2.2.0) — module

Sends a message to logged in users on Windows hosts

Authors: Jon Hawkesworth (@jhawkesworth)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Wraps the msg.exe command in order to send messages to Windows hosts.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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 }}

Inputs

    
to:
    default: '*'
    description:
    - Who to send the message to. Can be a username, sessionname or sessionid.
    type: str

msg:
    default: Hello world!
    description:
    - The text of the message to be displayed.
    - The message must be less than 256 characters.
    type: str

wait:
    default: 'no'
    description:
    - 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 I(wait)
      is C(yes), the message is sent to each logged on user in turn, waiting for the user
      to either press 'ok' or for the timeout to elapse before moving on to the next user.
    type: bool

display_seconds:
    default: 10
    description:
    - How long to wait for receiver to acknowledge message, in seconds.
    type: int

Outputs

display_seconds:
  description: Value of display_seconds module parameter.
  returned: success
  sample: 10
  type: str
msg:
  description: Test of the message that was sent.
  returned: changed
  sample: Automated upgrade about to start.  Please save your work and log off before
    22 July 2016 18:00:00
  type: str
rc:
  description: The return code of the API call.
  returned: always
  sample: 0
  type: int
runtime_seconds:
  description: How long the module took to run on the remote windows host.
  returned: success
  sample: 22 July 2016 17:45:51
  type: str
sent_localtime:
  description: local time from windows host when the message was sent.
  returned: success
  sample: 22 July 2016 17:45:51
  type: str
wait:
  description: Value of wait module parameter.
  returned: success
  sample: false
  type: bool

See also