0

i want to run a power shell script on remote windows machine. The PowerShell script will install software on C drive. The user which used to login is already in administrator group.

But when the command triggered manually in server it works but through ansible it is not working. The ansible task I have configured:

tasks:
    - name: Execute PowerShell script
      win_shell: |
        powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Path\to\your\script.ps1"

Any help?

1 Answer 1

1

You can use

become: yes
become_method: runas

https://stackoverflow.com/a/48675395/15962190

https://docs.ansible.com/ansible/2.7/user_guide/become.html#become-and-windows

1
  • Ansible 2.7 is EOL Commented Jun 14 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.