# run powershell command via ansible playbook

**URL:** <https://forum.ansible.com/t/run-powershell-command-via-ansible-playbook/34831>\
**Category:** Ansible Project\
**Created:** [March 23, 2021, 3:29am UTC](https://forum.ansible.com/t/run-powershell-command-via-ansible-playbook/34831 "2021-03-23T03:29:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Veliss](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@John\_Veliss](https://forum.ansible.com/u/John_Veliss)\
**Post date:** [March 23, 2021, 3:29am UTC](https://forum.ansible.com/t/run-powershell-command-via-ansible-playbook/34831/1 "2021-03-23T03:29:27Z")

</div>

Can anyone tell me how I would add the below powershell command into a playbook

PowerShell.exe (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [March 23, 2021, 4:34am UTC](https://forum.ansible.com/t/run-powershell-command-via-ansible-playbook/34831/2 "2021-03-23T04:34:01Z")

</div>

Please see win\_shell - [https://docs.ansible.com/ansible/latest/collections/ansible/windows/win\_shell\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_shell_module.html)  
and win\_command - [https://docs.ansible.com/ansible/latest/collections/ansible/windows/win\_command\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_command_module.html)
