# Configure Winrm playbook issue

**URL:** <https://forum.ansible.com/t/configure-winrm-playbook-issue/36542>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 19, 2022, 2:38pm UTC](https://forum.ansible.com/t/configure-winrm-playbook-issue/36542 "2022-04-19T14:38:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [April 19, 2022, 2:38pm UTC](https://forum.ansible.com/t/configure-winrm-playbook-issue/36542/1 "2022-04-19T14:38:23Z")

</div>

So I saw this example on github to configure remoting for ansible machines ([https://docs.ansible.com/ansible/latest/collections/community/windows/psexec\_module.html](https://docs.ansible.com/ansible/latest/collections/community/windows/psexec_module.html)), and try to make it work, but errors out:

ERROR! playbook entries must be either valid plays or ‘import\_playbook’ statements

My playbook is called multiple.yml and running it as:  
ansible-playbook -i hosts playbooks/multiple.yml

- name: Download and run ConfigureRemotingForAnsible.ps1 to setup WinRM  
community.windows.psexec:  
hostname: servername  
connection\_username: ‘{{ ansible\_user }}’  
connection\_password: ‘{{ ansible\_password }}’  
encrypt: yes  
executable: powershell.exe  
arguments: ‘-’  
stdin: |  
$ErrorActionPreference = “Stop”  
$sec\_protocols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault  
$sec\_protocols = $sec\_protocols -bor [Net.SecurityProtocolType]::Tls12  
[Net.ServicePointManager]::SecurityProtocol = $sec\_protocols  
$url = “[https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)”  
Invoke-Expression ((New-Object Net.WebClient).DownloadString($url))  
exit  
delegate\_to: localhost

What does this do and where is this defined:  
hostname: ‘{{ hostvars[inventory\_hostname][“ansible\_host”] | default(inventory\_hostname) }}’

My servername for the hostname is my server name, in my previous example, but trying to under the github example and what is trying to do.

We have 500+ machines on different domains, that we need ansible to connect to, and we are just using winrm currently to deploy new machines, which isnt an issue.

Issue is only connecting to servers, that werent built using ansible, hence need to run the configureremoting PS script to make them ansible ready to connect to.

Thanks
