# Windows print out contents of a file to stdout to debug

**URL:** <https://forum.ansible.com/t/windows-print-out-contents-of-a-file-to-stdout-to-debug/28354>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 17, 2018, 2:11pm UTC](https://forum.ansible.com/t/windows-print-out-contents-of-a-file-to-stdout-to-debug/28354 "2018-08-17T14:11:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SurferL](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@SurferL](https://forum.ansible.com/u/SurferL)\
**Post date:** [August 17, 2018, 2:11pm UTC](https://forum.ansible.com/t/windows-print-out-contents-of-a-file-to-stdout-to-debug/28354/1 "2018-08-17T14:11:14Z")

</div>

Hi,

I’m trying to print out a file’s content on a Windows role and then use the debug module to output to the console, this uses similar notation to print out files contents on a unix platform for ansible.

> - name: windows | register log file
> 
> shell: “type c:\log.txt”
> 
> register: logFile
> 
> - name: windows | print out log file
> 
> debug:
> 
> msg: “{{ logFile.stdout }}”

However, I’m getting this error on the first step:

> TASK [templates : windows | register log file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> [WARNING]: FATAL ERROR DURING FILE TRANSFER:
> 
> fatal: [inf]: FAILED! =\> {“msg”: "winrm send\_input failed; \nstdout: Unable to initialize device PRN\r\nUnable to initialize device PRN\r\nUnable to initialize device PRN\r\n\nstderr ANSIBALLZ\_WRAPPER : The term ‘ANSIBALLZ\_WRAPPER’ is not recognized as the name of a cmdlet, function, script file, or \r\noperable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try \r\nagain.\r\nAt line:1 char:1\r\n+ ANSIBALLZ\_WRAPPER = True # For test-module script to tell this is a A …

etc…

Can someone point me how to do this correctly on Windows? (using Ansible 2.6.2)

Thanks in advance! 🙂

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 17, 2018, 3:23pm UTC](https://forum.ansible.com/t/windows-print-out-contents-of-a-file-to-stdout-to-debug/28354/2 "2018-08-17T15:23:45Z")

</div>

> Hi,
> 
> I'm trying to print out a file's content on a Windows role and then use the  
> debug module to output to the console, this uses similar notation to print  
> out files contents on a unix platform for ansible.
> 
> - name: windows | register log file  
> shell: "type c:\\log.txt"  
> register: logFile

\<snio /\>

> Can someone point me how to do this correctly on Windows? (using Ansible  
> 2.6.2)

It's in the documentation  
[https://docs.ansible.com/ansible/2.6/modules/shell\_module.html#synopsis](https://docs.ansible.com/ansible/2.6/modules/shell_module.html#synopsis)

The second bullet point reads "For Windows targets, use the win\_shell module instead."

---

<div class="post-metadata">

**Author:** ![SurferL](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@SurferL](https://forum.ansible.com/u/SurferL)\
**Post date:** [August 17, 2018, 3:28pm UTC](https://forum.ansible.com/t/windows-print-out-contents-of-a-file-to-stdout-to-debug/28354/3 "2018-08-17T15:28:18Z")

</div>

Oof yeah that’s it - thank you!
