2

I tried to create a task in ansible playbook using win_powershell module but everytime I run the playbook, the task is hanging. Does anyone have a solution ? I`m pretty new to ansible.

Here is the yml file:

---
- name: notification
 hosts: windows
 become: false
 gather_facts: false
 tasks:

   - name: message
      ansible.windows.win_powershell:
         script: |
           Add-Type -AssemblyName PresentationFramework
           [System.Windows.MessageBox]::Show('message')
   
   
1
  • 1
    The task is hanging because the Messagebox is active. However it is not shown to the currently logged in user but for Session 0 - which means the MessageBox is not visible at all. If you go into Task Manager you can kill the underlying Powershell-process and your Playbook would continue. Commented Dec 8, 2022 at 11:07

1 Answer 1

1

Perhaps one of the following modules might be more suitable than running a powershell command. You'd need to install the community modules for either of these.

The community.windows.win_msg module. Usage:

- name: Display message.
  community.windows.win_msg:
    msg: 'message'

Ansible also supports toast notifications via community.windows.win_toast module

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, Justin ! I voted your answer as helpful but it wont display due that Im too new to this site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.