# Ansible windows with PowerShell -ValueError: zero length field name in format

**URL:** <https://forum.ansible.com/t/ansible-windows-with-powershell-valueerror-zero-length-field-name-in-format/15635>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 9, 2014, 5:36pm UTC](https://forum.ansible.com/t/ansible-windows-with-powershell-valueerror-zero-length-field-name-in-format/15635 "2014-07-09T17:36:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![L\_Venkatraman](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@L\_Venkatraman](https://forum.ansible.com/u/L_Venkatraman)\
**Post date:** [July 9, 2014, 5:36pm UTC](https://forum.ansible.com/t/ansible-windows-with-powershell-valueerror-zero-length-field-name-in-format/15635/1 "2014-07-09T17:36:59Z")

</div>

Hi

I hit upon an issue using ansible to run PowerShell commands against windows nodes. I followed the instructions and got the basics working. On my linux controller node I had Python 2.6.6 and when running the simple setup module I got this error:

python ansible windows -m setup  
Traceback (most recent call last):  
File “/root/projects/ansible/lib/ansible/runner/connection\_plugins/winrm.py”, line 150, in exec\_command  
result = self.\_winrm\_exec(cmd\_parts[0], cmd\_parts[1:], from\_exec=True)  
File “/root/projects/ansible/lib/ansible/runner/connection\_plugins/winrm.py”, line 121, in \_winrm\_exec  
vvvv(‘WINRM RESULT %r’ % response, host=self.host)  
File “/usr/lib/python2.6/site-packages/winrm/ **init**.py”, line 12, in **repr**  
self.status\_code, self.std\_out[:20], self.std\_err[:20])  
ValueError: zero length field name in format

It is because the code in **repr** () of /winrm/ **init**.py has omitted positional argument specifier in the format string which will work only in Python 2.7 & above but not in Python 2.6, which is suggested in Ansible docs.

I fixed the above by changing the line to:

return ‘\<Response code {0}, out “{1}”, err “{2}”\>’.format(…)

I thought I would share this so that it might help anyone who gets stuck with this issue.

-Venkat

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 9, 2014, 7:57pm UTC](https://forum.ansible.com/t/ansible-windows-with-powershell-valueerror-zero-length-field-name-in-format/15635/2 "2014-07-09T19:57:47Z")

</div>

Thanks!

Can you file this in a github ticket at [github.com/ansible/ansible](http://github.com/ansible/ansible) so we don’t lose track of this?

---

<div class="post-metadata">

**Author:** ![L\_Venkatraman](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@L\_Venkatraman](https://forum.ansible.com/u/L_Venkatraman)\
**Post date:** [July 10, 2014, 5:40am UTC](https://forum.ansible.com/t/ansible-windows-with-powershell-valueerror-zero-length-field-name-in-format/15635/3 "2014-07-10T05:40:40Z")

</div>

Welcome ! Sure I shall have filed a ticket.

-Venkat
