# Powershell Script execution

**URL:** <https://forum.ansible.com/t/powershell-script-execution/31823>\
**Category:** Ansible Project\
**Created:** [December 15, 2019, 3:05pm UTC](https://forum.ansible.com/t/powershell-script-execution/31823 "2019-12-15T15:05:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikrant](https://avatars.discourse-cdn.com/v4/letter/v/cc9497/32.png) [@Vikrant](https://forum.ansible.com/u/Vikrant)\
**Post date:** [December 15, 2019, 3:05pm UTC](https://forum.ansible.com/t/powershell-script-execution/31823/1 "2019-12-15T15:05:38Z")

</div>

Hi All,

I’m curious if this is possible,

At a very high level, for the connectivity testing on different servers, I’ve to follow below steps:

1. Push two Powershell script to each server
2. Run the two PowerShell scripts on each server (listener and client)
3. Capture output and email to stakeholders

Can this be done with ansible?

regards

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 15, 2019, 5:07pm UTC](https://forum.ansible.com/t/powershell-script-execution/31823/2 "2019-12-15T17:07:56Z")

</div>

Yes

---

<div class="post-metadata">

**Author:** ![Vikrant](https://avatars.discourse-cdn.com/v4/letter/v/cc9497/32.png) [@Vikrant](https://forum.ansible.com/u/Vikrant)\
**Post date:** [December 16, 2019, 6:40am UTC](https://forum.ansible.com/t/powershell-script-execution/31823/3 "2019-12-16T06:40:45Z")

</div>

Thanks, can you please advise how to capture the output and emailed to stakeholders.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 16, 2019, 8:38am UTC](https://forum.ansible.com/t/powershell-script-execution/31823/4 "2019-12-16T08:38:11Z")

</div>

Sure. First register the output:

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_variables.html#registering-variables](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#registering-variables)

Then send the mail:

[https://docs.ansible.com/ansible/latest/modules/mail\_module.html](https://docs.ansible.com/ansible/latest/modules/mail_module.html)

Dick
