# WinRM - running ansible on widnows returning error

**URL:** <https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 1, 2018, 10:20am UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918 "2018-11-01T10:20:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadim\_mansour](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nadim\_mansour](https://forum.ansible.com/u/nadim_mansour)\
**Post date:** [November 1, 2018, 10:20am UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/1 "2018-11-01T10:20:19Z")

</div>

How can I let ansible run on windows node(windows server 2012 machine) ??  
I ran the belwo commands on power shell before running the ansible script :

**netsh advfirewall firewall add rule name=“Allow WinRM (Http)” dir=in localport=5985 protocol=tcp action=allow enable=yes**

**netsh advfirewall firewall add rule name=“Allow WinRM (Https)” dir=in localport=5986 protocol=tcp action=allow enable=yes**

I am recieving the below error

fatal: [uat\_cdxdb]: UNREACHABLE! =\> {

“changed”: false,

“msg”: “ssl: HTTPSConnectionPool(host=‘10.1.116.151’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<urllib3.connection.VerifiedHTTPSConnection object at 0x108cfd450\>: Failed to establish a new connection: [Errno 61] Connection refused’,))”,

“unreachable”: true

}

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 1, 2018, 10:38am UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/2 "2018-11-01T10:38:29Z")

</div>

Run this PowerShell script on your windows machine: [https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)

That will configure the necessary changes to allow Ansible to connect to windows.

---

<div class="post-metadata">

**Author:** ![nadim\_mansour](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nadim\_mansour](https://forum.ansible.com/u/nadim_mansour)\
**Post date:** [November 1, 2018, 10:44am UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/3 "2018-11-01T10:44:52Z")

</div>

is thier another way like doing manual steps or rules.  
The client will not allow us to run the script on his amchines  
could you please help or advice ?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [November 1, 2018, 12:26pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/4 "2018-11-01T12:26:16Z")

</div>

You can look at the script and see what it does to enable the firewall rules. I find it amusing they won’t allow scripts when you can still run arbitrary commands.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![nadim\_mansour](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nadim\_mansour](https://forum.ansible.com/u/nadim_mansour)\
**Post date:** [November 1, 2018, 1:06pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/5 "2018-11-01T13:06:58Z")

</div>

I am enabling the below rules:

netsh advfirewall firewall add rule name=“Allow WinRM (Http)” dir=in localport=5985 protocol=tcp action=allow enable=yes

netsh advfirewall firewall add rule name=“Allow WinRM (Https)” dir=in localport=5986 protocol=tcp action=allow enable=yes

but it seems on https a certificate is needed !? cause I am still not able to run ansible on the windows server

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [November 1, 2018, 1:13pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/6 "2018-11-01T13:13:38Z")

</div>

Can you share winrm configuration?

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 1, 2018, 2:13pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/7 "2018-11-01T14:13:02Z")

</div>

I have not done it manually.

My be take a look at below article: [https://www.virtualtothecore.com/en/configuring-windows-machines-for-ansible/](https://www.virtualtothecore.com/en/configuring-windows-machines-for-ansible/)

It looks like he was using SolarWinds Remote Execution Enabler for PowerShell: [https://www.solarwinds.com/free-tools/remote-execution-enabler-for-powershell](https://www.solarwinds.com/free-tools/remote-execution-enabler-for-powershell)

---

<div class="post-metadata">

**Author:** ![nadim\_mansour](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nadim\_mansour](https://forum.ansible.com/u/nadim_mansour)\
**Post date:** [November 1, 2018, 2:35pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/8 "2018-11-01T14:35:37Z")

</div>

Please find below the screent shot  
I run the two rules command for http and https listener  
and I run winrm qc

but its listining only to http

---

<div class="post-metadata">

**Author:** ![nadim\_mansour](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@nadim\_mansour](https://forum.ansible.com/u/nadim_mansour)\
**Post date:** [November 1, 2018, 2:38pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/9 "2018-11-01T14:38:02Z")

</div>

![Screen Shot 2018-11-01 at 4.33.56 PM.png](https://us1.discourse-cdn.com/ansible/original/2X/b/bcbd2fd14aeab99ab3f892b4e4724933258a685c.png)

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [November 1, 2018, 7:29pm UTC](https://forum.ansible.com/t/winrm-running-ansible-on-widnows-returning-error/28918/10 "2018-11-01T19:29:14Z")

</div>

Yes you need a certificate for https just like any https endpoint. The Configure script will generate a self signed one for you as it is needlessly complex in older versions of PowerShell to generate your own.
