# Issuew when doing a When conditional with win\_copy

**URL:** <https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308>\
**Category:** Ansible Developer\
**Created:** [September 18, 2019, 4:04pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308 "2019-09-18T16:04:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TD1](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TD1](https://forum.ansible.com/u/TD1)\
**Post date:** [September 18, 2019, 4:04pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308/1 "2019-09-18T16:04:30Z")

</div>

Hello all,  
I am trying to do a conditional based on the output of a win\_shell. When I run this it’s as if it doesn’t see the conditional and copies to to all inventory not just what is coming back as True. Any ideas?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 18, 2019, 4:47pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308/2 "2019-09-18T16:47:03Z")

</div>

Your `when` statement, needs to be indented to the same level as `win_copy`, not the same level as `dest`. Also it needs to be the lowercased `when`

---

<div class="post-metadata">

**Author:** ![TD1](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TD1](https://forum.ansible.com/u/TD1)\
**Post date:** [September 18, 2019, 5:07pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308/3 "2019-09-18T17:07:28Z")

</div>

Matt, I now see it is attempting it but I get and erroron win\_copy:{  
“msg”: “The conditional check ‘ansible\_facts[‘results.stdout’] == "True"’ failed. The error was: error while evaluating conditional (ansible\_facts[‘results.stdout’] == "True"): ‘dict object’ has no attribute ‘results.stdout’\n\nThe error appears to be in ‘/var/lib/awx/projects/\_8\_\_test\_project/Win\_Feature\_SQL.yml’: line 11, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n output: "{{ results.stdout }}"\n - win\_copy:\n ^ here\n”,  
“\_ansible\_no\_log”: false  
}

I do see my results from win\_shell though:

{  
“changed”: false,  
“ansible\_facts”: {  
“output”: “True\n”  
},  
“\_ansible\_no\_log”: false  
}

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 18, 2019, 5:18pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308/4 "2019-09-18T17:18:00Z")

</div>

`results.stdout` is not a literal variable name. Instead what you are likely looking for is:

when: results.stdout|trim == ‘True’

or since you use `set_fact` in between, it could also be:

when: output|trim == ‘True’

---

<div class="post-metadata">

**Author:** ![TD1](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TD1](https://forum.ansible.com/u/TD1)\
**Post date:** [September 18, 2019, 5:52pm UTC](https://forum.ansible.com/t/issuew-when-doing-a-when-conditional-with-win-copy/31308/5 "2019-09-18T17:52:23Z")

</div>

That worked, Thanks for the help Matt. Much appreciated
