# Run Powershell script on remote

**URL:** <https://forum.ansible.com/t/run-powershell-script-on-remote/18823>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 22, 2015, 4:55pm UTC](https://forum.ansible.com/t/run-powershell-script-on-remote/18823 "2015-07-22T16:55:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [July 22, 2015, 4:55pm UTC](https://forum.ansible.com/t/run-powershell-script-on-remote/18823/1 "2015-07-22T16:55:41Z")

</div>

Apologies for what must be a very dumb question, but how do I run a Powershell script which is located on a remote Windows machine? And, can I run a script that’s located on the Ansible host?

Many thanks!

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 22, 2015, 8:20pm UTC](https://forum.ansible.com/t/run-powershell-script-on-remote/18823/2 "2015-07-22T20:20:09Z")

</div>

You can use the ‘raw’ module to run a powershell script that is already on the remote machine (or any exe), and you can use the ‘script’ module to have ansible transfer the powershell script from your ansible controller to your managed host and then run the powershell script.

If possible though, use the windows modules for controlling your Windows machines (or create your own), they integrate better with the rest of ansible (you can take control of whether ansible returns ‘ok’ or ‘changed’ with your own module).

If you are able to clone ansible from github there are many useful examples of using raw, script and other windows modules in the test/integration/roles/ dirs

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [July 23, 2015, 1:16pm UTC](https://forum.ansible.com/t/run-powershell-script-on-remote/18823/3 "2015-07-23T13:16:28Z")

</div>

Thank you, Jon. I really appreciate the many contributions that you make to the list!
