# How to save the O/P of ansible playbook into a file in windows enviroment

**URL:** <https://forum.ansible.com/t/how-to-save-the-o-p-of-ansible-playbook-into-a-file-in-windows-enviroment/29815>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [March 4, 2019, 7:49am UTC](https://forum.ansible.com/t/how-to-save-the-o-p-of-ansible-playbook-into-a-file-in-windows-enviroment/29815 "2019-03-04T07:49:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [March 4, 2019, 7:49am UTC](https://forum.ansible.com/t/how-to-save-the-o-p-of-ansible-playbook-into-a-file-in-windows-enviroment/29815/1 "2019-03-04T07:49:50Z")

</div>

Hi All,

I have a playbook, using REST API getting the details of a process in JSON format. I want to save that JSON o/p to a file in windows environment. Can any one please help me.

sample playbook:

---

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [March 4, 2019, 8:11am UTC](https://forum.ansible.com/t/how-to-save-the-o-p-of-ansible-playbook-into-a-file-in-windows-enviroment/29815/2 "2019-03-04T08:11:56Z")

</div>

Hi,

I tried the following, im saving the output to a file and trying that to copy to a file. but not working can any one help.

---

<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:** [March 4, 2019, 11:10am UTC](https://forum.ansible.com/t/how-to-save-the-o-p-of-ansible-playbook-into-a-file-in-windows-enviroment/29815/3 "2019-03-04T11:10:32Z")

</div>

> Hi,
> 
> I tried the following, im saving the output to a file and trying that to  
> copy to a file. but not working can any one help.
> 
> ---  
> - hosts: windows  
> &nbsp;&nbsp;remote\_user: admin  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;- name: rest api  
> &nbsp;&nbsp;&nbsp;&nbsp;win\_uri:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url: [http://example.com](http://example.com)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method: GET  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: json\_ouput

Your register is indented to far, it must be on the same level as name and win\_uri.

> &nbsp;&nbsp;- name: copying the content to a file  
> &nbsp;&nbsp;&nbsp;&nbsp;copy: content="{{ json\_ooutput}}" dest=/path/to/destination/file\_name

copy is for linux, win\_copy is for Windows.

And if you check the documentation under return values for win\_uri  
[https://docs.ansible.com/ansible/2.4/win\_uri\_module.html#return-values](https://docs.ansible.com/ansible/2.4/win_uri_module.html#return-values)  
you see that the output will be in json\_ouput.content or json\_ouput.json depending on the use of the module and the return of the server.

You can always use this to see the content.

- debug: var=json\_ouput
