简体   繁体   中英

Windows powershell messagebox using Ansible

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')
   
   

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM