# Windows modules get a 500 error from WinRM

**URL:** <https://forum.ansible.com/t/windows-modules-get-a-500-error-from-winrm/27501>\
**Category:** AWX Project\
**Tags:** windows, awx\
**Created:** [May 10, 2018, 9:12am UTC](https://forum.ansible.com/t/windows-modules-get-a-500-error-from-winrm/27501 "2018-05-10T09:12:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus\_von\_Gerhardt](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Marcus\_von\_Gerhardt](https://forum.ansible.com/u/Marcus_von_Gerhardt)\
**Post date:** [May 10, 2018, 9:12am UTC](https://forum.ansible.com/t/windows-modules-get-a-500-error-from-winrm/27501/1 "2018-05-10T09:12:01Z")

</div>

Hello,

I’m working on getting some scheduled tasks on AWX for Windows servers, which will basically copy (with win\_copy) some powershell scripts from the remote server and then run these scripts on the Windows servers (with win\_command).

I define the following host vars for the Windows servers:

ansible\_user: user  
ansible\_password: password

ansible\_port: 5985  
ansible\_connection: winrm  
ansible\_winrm\_transport: ntlm  
ansible\_become: false  
ansible\_winrm\_server\_cert\_validation: ignore  
ansible\_winrm\_operation\_timeout\_sec: 120  
ansible\_winrm\_read\_timeout\_sec: 180

These are the tasks:

- name: Copy folder contents recursively  
win\_copy:  
src: files/  
dest: C:\Utils\scripts

- name: Run powershell scripts  
win\_command: powershell.exe -ExecutionPolicy Unrestricted -File C:\Utils\scripts\install\_app.ps1

Both tasks return the error:  
“msg”: “ntlm: (u’http’, u’Bad HTTP response returned from server. Code 500’)”,

I was running AWX 1.0.2 (docker image) with Ansible 2.4.2, but tried upgrading to Ansible 2.5.2 and still get the same error.

**Fact 1: I don’t have any issues running this playbook from my local machine (OSX), also running Ansible 2.5.2.**  
**Fact 2: I’ve connected to the container (docker exec), went to the project folder (under /var/lib/awx/projects/) and tried to run the playbook from there, it worked like a charm.**  
**Fact 3: I’ve installed pywinrm in the container, didn’t make a difference.**

I was wondering if AWX is throwing extra stuff (e.g. environment and/or extra variables) that could be causing the problem for me.

Any help is appreciated.  
Regards,

Marcus

---

<div class="post-metadata">

**Author:** ![Marcus\_von\_Gerhardt](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Marcus\_von\_Gerhardt](https://forum.ansible.com/u/Marcus_von_Gerhardt)\
**Post date:** [May 10, 2018, 12:53pm UTC](https://forum.ansible.com/t/windows-modules-get-a-500-error-from-winrm/27501/2 "2018-05-10T12:53:51Z")

</div>

Looking deeper into this, I’ve enabled the winRM analytical logs and can see in the Event Viewer this is the reason behind the 500 error: **extraErrorInfo1 Request was unencrypted and the server does not support unencrypted traffic**

If I try to set ansible\_winrm\_message\_encryption to always, I get the following:  
[WARNING]: ansible\_winrm\_message\_encryption unsupported by pywinrm (is an up- to-date version of pywinrm installed?)

And the message ends up going unencrypted again.

Even though I’ve installed it manually on the container:  
  
**[root@awx awx]# pip show pywinrm  
Name: pywinrm  
Version: 0.3.0**

I know I can set ansible to connect via HTTPS over port 5986, but I was trying to avoid that as we have a ton of servers which don’t have HTTPS/5986 enabled.

Can anyone suggest on the reason why the executions in AWX and in the container’s command-line would have different outcomes?

Many thanks,  
Marcus

---

<div class="post-metadata">

**Author:** ![Marcus\_von\_Gerhardt](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Marcus\_von\_Gerhardt](https://forum.ansible.com/u/Marcus_von_Gerhardt)\
**Post date:** [May 11, 2018, 1:05pm UTC](https://forum.ansible.com/t/windows-modules-get-a-500-error-from-winrm/27501/3 "2018-05-11T13:05:51Z")

</div>

if any one comes across this issue, mine was solved by upgrading pywinrm in the AWX virtualenv:

so, basically:

. /var/lib/awx/venv/ansible/bin/activate

pip install --upgrade pywinrm
