# Powershell code in Ansible playbook returns non zero error code

**URL:** <https://forum.ansible.com/t/powershell-code-in-ansible-playbook-returns-non-zero-error-code/32654>\
**Category:** Ansible Project\
**Tags:** windows, awx\
**Created:** [April 10, 2020, 2:33pm UTC](https://forum.ansible.com/t/powershell-code-in-ansible-playbook-returns-non-zero-error-code/32654 "2020-04-10T14:33:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasir\_Nasir](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@Nasir\_Nasir](https://forum.ansible.com/u/Nasir_Nasir)\
**Post date:** [April 10, 2020, 2:33pm UTC](https://forum.ansible.com/t/powershell-code-in-ansible-playbook-returns-non-zero-error-code/32654/1 "2020-04-10T14:33:52Z")

</div>

![awx-error.PNG](https://us1.discourse-cdn.com/ansible/original/2X/1/17b05c766c4335e20ed65d7a93596bfab847d067.png)

 ![code.PNG](https://us1.discourse-cdn.com/ansible/original/2X/f/f8b5c33e49755ee76a3c183532ac28475b79d032.png)

Hi All, i have an issue respect to powershell code which i am using to delete file from windows machine using an Ansible code via AWX i have mongodb lookup value= ‘C:/Users/abcd/abcd/’,‘C:/abc/’, code is delete the file in the folder but returning error i have attached the code and error i am getting please help me on this, i have get this done over the weekend

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 10, 2020, 2:44pm UTC](https://forum.ansible.com/t/powershell-code-in-ansible-playbook-returns-non-zero-error-code/32654/2 "2020-04-10T14:44:08Z")

</div>

Hi Nasir

Sorry to hear this, it does sound like bad planning on your side.  
Please don't make that our problem, this is a best effort support list  
with no SLAs etc.  
On that note - you will significantly increase the chances of someone  
helping you if you post text instead of mostly unreadable screen  
dumps.

Dick

---

<div class="post-metadata">

**Author:** ![David\_Foley](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@David\_Foley](https://forum.ansible.com/u/David_Foley)\
**Post date:** [April 10, 2020, 9:51pm UTC](https://forum.ansible.com/t/powershell-code-in-ansible-playbook-returns-non-zero-error-code/32654/3 "2020-04-10T21:51:03Z")

</div>

Have you Tested the Powershell Code on a local machine to make sure it’s working ?  
You could:

- Create the Powershell Script in Name.ps1
- Copy Name.ps1 to Temp
- Run it and then Remove name.ps1 from Temp Folder

In the past, I had issues with running Powershell Scripts using Ansible, Now if i need to use Powershell, Adding / Removing AD Objects I just use SaltStack for that.
