# Powershell script from Ansible Playbook

**URL:** <https://forum.ansible.com/t/powershell-script-from-ansible-playbook/32084>\
**Category:** Ansible Project\
**Created:** [January 29, 2020, 12:56pm UTC](https://forum.ansible.com/t/powershell-script-from-ansible-playbook/32084 "2020-01-29T12:56:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Prasha](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@Sai\_Prasha](https://forum.ansible.com/u/Sai_Prasha)\
**Post date:** [January 29, 2020, 12:56pm UTC](https://forum.ansible.com/t/powershell-script-from-ansible-playbook/32084/1 "2020-01-29T12:56:34Z")

</div>

I have .psl file i want to run that file on Ansible nodes ,So when i try to invoke the .psl file using adhoc command : **ansible win1 -m win\_command -a “powershell.exe -File C:\Sample\tomeescript.ps1” ,** It works fine  
When i try to do the same with win\_command module ,its failing

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 29, 2020, 1:00pm UTC](https://forum.ansible.com/t/powershell-script-from-ansible-playbook/32084/2 "2020-01-29T13:00:01Z")

</div>

> I have .psl file i want to run that file on Ansible nodes ,So when i try to invoke the .psl file using adhoc command :  
> \*ansible win1 -m win\_command -a "powershell.exe -File C:\Sample\tomeescript.ps1" , \*It works fine  
> When i try to do the same with win\_command module ,its failing  
> ---  
> - hosts:win1  
> tasks:  
> - name : run psl  
> win\_command: powershell.exe -  
> args:  
> chdir: C:\Sample\tomeescript.ps1
> 
> How to run the powershell script using playbook . I am not sure what mistake i did in the playbook

Excuse me, but the name of the script certainly doesn't belong into the chdir parameter.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
