Powershell script from Ansible Playbook

18 views
Skip to first unread message

Sai Prasha

unread,
Jan 29, 2020, 7:56:35 AM1/29/20
to Ansible Project
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

Stefan Hornburg (Racke)

unread,
Jan 29, 2020, 8:00:35 AM1/29/20
to ansible...@googlegroups.com
On 1/29/20 1:56 PM, Sai Prasha wrote:
> 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
Racke
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/543e3dca-4392-4edf-a1db-cb274e7cb544%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/543e3dca-4392-4edf-a1db-cb274e7cb544%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages