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:

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

Any help?

1 Answer 1


You can use

become: yes
become_method: runas



  • 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.