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

Your Answer

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

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