The issue you are seeing is that you are using the stdout_lines return value which is the stdout of the script that was run but split into a list on each newline. You want to use the stdout return value from the script which would be the full stdout of your json. The task's would look something like this
- name: Run Powershell script and return json including zip file name script: files/script.ps1 register: script_result # this uses the filter from_json to convert the raw json string to a # dictionary in Ansible so you can access the variables a lot easier - name: convert the script result to a dict in Ansible set_fact: script_filename: '{{ script_result.stdout|from_json }}' - name: copy files win_copy: src: C:\Temp\{{ script_filename.Name }} # if Name in the JSON is 'latest-ansible v0.1.zip', then src sent to win_copy is 'C:\Temp\latest-ansible v0.1.zip' dest: C:\Inetpub\ remote_src: yes # you need to set this so the copy happens remote to remote, by default src is based on the local Ansible controller I haven't tested this, but see how you go, it should bring you onto the right track. A few more notes; - You are getting warnings saying ansible_winrm_cert_validation is unsupported, the variable should actually be ansible_winrm_server_cert_validation, if you remove the definition of ansible_winrm_cert_validation then those warnings will go away - In your win_copy task, you quoted the jinja2 block, you only need to quote it when the value starts with a block like so # doesn't need quoting as the value itself doesn't start with { key: value/{{ variable }} # needs to be quoted as the value does start with { key: "{{ variable }}" Thanks Jordan -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b9c24d75-0fdb-49a2-881e-3dcefc2b6df4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.