# WinRM configuration script error

**URL:** <https://forum.ansible.com/t/winrm-configuration-script-error/18401>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [June 4, 2015, 10:36am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401 "2015-06-04T10:36:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rene\_Metery](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rene\_Metery](https://forum.ansible.com/u/Rene_Metery)\
**Post date:** [June 4, 2015, 10:36am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/1 "2015-06-04T10:36:37Z")

</div>

Hi,

I am currently configuring a windows computer to accept remote access from ansible and I am having a problem while running the script ConfigureRemotingForAnsible.ps1.

Here is the error :

PS D:\Ansible\Power Shell 3\> .\ConfigureRemotingForAnsible.ps1  
Unable to establish an HTTP or HTTPS remoting session.  
Au caractère D:\Ansible\Power Shell 3\ConfigureRemotingForAnsible.ps1:129 : 5

- Throw “Unable to establish an HTTP or HTTPS remoting session.”
- 

```auto

```

- CategoryInfo : OperationStopped: (Unable to estab…moting session.:String) , RuntimeException
- FullyQualifiedErrorId : Unable to establish an HTTP or HTTPS remoting session.

I have checked my authentication configuration an it seems ok.

PS D:\Ansible\Power Shell 3\> winrm get winrm/config  
Config  
MaxEnvelopeSizekb = 500  
MaxTimeoutms = 60000  
MaxBatchItems = 32000  
MaxProviderRequests = 4294967295  
Client  
NetworkDelayms = 5000  
URLPrefix = wsman  
AllowUnencrypted = false  
Auth  
Basic = true  
Digest = true  
Kerberos = true  
Negotiate = true  
Certificate = true  
CredSSP = false

If you have any idea about the problem it will greatly help me.  
I can’t find any post about that problem.

Cheers,

René METERY

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [June 4, 2015, 4:10pm UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/2 "2015-06-04T16:10:18Z")

</div>

not sure here but are you using the latest version of the configure script ? [https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)  
also is the winrm server running on port 5985 5986, iirc

---

<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:** [June 4, 2015, 7:01pm UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/3 "2015-06-04T19:01:34Z")

</div>

Do you have windows management framework installed?

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [June 5, 2015, 4:22am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/4 "2015-06-05T04:22:13Z")

</div>

What does $PSVersionTable return for you?

PS \> $PSVersionTable

Name Value

* * *

PSVersion 4.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.34209  
BuildVersion 6.3.9600.16406  
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}  
PSRemotingProtocolVersion 2.2

---

<div class="post-metadata">

**Author:** ![Rene\_Metery](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rene\_Metery](https://forum.ansible.com/u/Rene_Metery)\
**Post date:** [June 5, 2015, 8:35am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/5 "2015-06-05T08:35:04Z")

</div>

Here is the output of : PS \> $PSVersionTable

Name Value

* * *

PSVersion 3.0  
WSManStackVersion 3.0  
SerializationVersion 1.1.0.1  
CLRVersion 4.0.30319.34209  
BuildVersion 6.2.9200.16398  
PSCompatibleVersions {1.0, 2.0, 3.0}  
PSRemotingProtocolVersion 2.2

I have downloaded the latest version of the script and have the windows management framework installed.  
The server is up and running because I’ve already managed to run a command remotely on my own computer through a winrs command.

In fact, I’ve managed to run the ConfigureRemotingForAnsible.ps1 script completely by just bypassing the Test a remoting connection to localhost, which should work. by commenting the lines 115 to 130. I know this is not elegant.

After that operation, I did a simple “ansible windows -m win\_ping” command from my server to the windows client and it worked !

Still don’t know why this test during the configuration script execution failed.

---

<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:** [June 5, 2015, 11:34am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/6 "2015-06-05T11:34:58Z")

</div>

My guess would be firewall configuration on the windows machine is stopping the remoting to localhost from working.  
The other place to look would be in the winrm configuration.  
Sometimes checking the windows event log can be helpful - have you looked there?

Jon

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [June 5, 2015, 12:59pm UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/7 "2015-06-05T12:59:49Z")

</div>

Any helpful info here?

[http://powershell.com/cs/media/p/7257.aspx#windows-powershell-remoting](http://powershell.com/cs/media/p/7257.aspx#windows-powershell-remoting)

Similar to the firewall check, check the trusted hosts. That was my problem.

---

<div class="post-metadata">

**Author:** ![Rene\_Metery](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rene\_Metery](https://forum.ansible.com/u/Rene_Metery)\
**Post date:** [June 8, 2015, 7:09am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/8 "2015-06-08T07:09:59Z")

</div>

Checking the windows evetn log was so obvious that I didn’t think about it.  
While running the script and getting the error, the event has recorded this event (sorry this is in french but I think it is understandable) :

08/06/2015 08:34:20 142 Erreur L’opération WSMan CreateShell a échoué, code d’erreur 5  
08/06/2015 08:34:20 254 Information Transfert d’activité  
08/06/2015 08:34:20 162 Erreur L’authentification de l’utilisateur a échoué. Les informations d’identification n’ont pas fonctionné.

When I dig into the authentication error information I can see that the user listed is ITEM-81502\efibtf. This is the local user (with admin rights) that I am using to run the configuration script.  
On the Control Machine I am using the same user but without the computer prefix and it works fine.

Maybe I should run the script as admin instead of running it as an user with admin rights ?  
Otherwise, do you have any idea how can I manage to authenticate without having the user prefixed with the computer name ?

---

<div class="post-metadata">

**Author:** ![Rene\_Metery](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rene\_Metery](https://forum.ansible.com/u/Rene_Metery)\
**Post date:** [June 8, 2015, 7:12am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/9 "2015-06-08T07:12:03Z")

</div>

Thanks for the link, I will check into it.

---

<div class="post-metadata">

**Author:** ![Snehit](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Snehit](https://forum.ansible.com/u/Snehit)\
**Post date:** [February 15, 2018, 8:53am UTC](https://forum.ansible.com/t/winrm-configuration-script-error/18401/10 "2018-02-15T08:53:27Z")

</div>

Hi Rene ,

Have you able to resolve this issue ?  
I am also have same problem.

\<\<

Unable to establish an HTTP or HTTPS remoting session.  
At C:\Users\snehit.rahate\Desktop\ConfigureRemotingForAnsible.ps1:404 char:5

- Throw “Unable to establish an HTTP or HTTPS remoting session.”
- 

```auto

```

- CategoryInfo : OperationStopped: (Unable to estab…moting session.:String) , RuntimeException
- FullyQualifiedErrorId : Unable to establish an HTTP or HTTPS remoting session.

> >

Thanks,  
Snehit

On  
Monday, 8 June 2015 12:42:03 UTC+5:30, Rene Metery wrote:
