# How to have windows configured with ansible automatically

**URL:** <https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 1, 2016, 4:45am UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041 "2016-04-01T04:45:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepa\_Yr](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Deepa\_Yr](https://forum.ansible.com/u/Deepa_Yr)\
**Post date:** [April 1, 2016, 4:45am UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/1 "2016-04-01T04:45:18Z")

</div>

Hi

My requirement is Provision a windows machine and run the playbooks without manual intervention. In this case, we cannot run the playbooks as windows is not configured for ansible. ie ConfigureRemotingForAnsible.ps1 is not executed on windows machine.

Is there a way to connect to windows machine from ansible control machine and run the powershell script, after that playbooks can be run.

Thanks

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 3, 2016, 3:17pm UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/2 "2016-04-03T15:17:55Z")

</div>

Hi,

You don’t mention which version(s) of windows you are using. I think Server 2012 R2 may actually be configured for WinRM connections by default, so you might be able to connect without first running ConfigureRemotingForAnsible.ps1

Also if you are using AWS see this [https://www.ansible.com/blog/easily-provision-windows](https://www.ansible.com/blog/easily-provision-windows)

I get round this by using a vmware template with a run once script which runs ConfigureRemotingForAnsible.ps1 when the virtual machine is first created from the template.

I believe you can also create an autorun xml file and add it to the root of the windows ISO which allows for a fully automated installation of windows from ISO but I have not tried this myself.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Deepa\_Yr](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Deepa\_Yr](https://forum.ansible.com/u/Deepa_Yr)\
**Post date:** [April 4, 2016, 6:29am UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/3 "2016-04-04T06:29:36Z")

</div>

Hi

Thanks for your response. I am using Windows 2012 R2 standard edition. Without running the ConfigureRemotingForAnsible.ps1, I am not able to connect to windows machine from Ansible controller. We are provisioning machines on soft layer. Need to see whether an option/permission to create a template is available with us or not. So looking for some option to get the script run once the machine is provisioned. Tried using pywinrm , but that needs some winrm variables to set , so the connection happens through python.

---

<div class="post-metadata">

**Author:** ![Sesh](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Sesh](https://forum.ansible.com/u/Sesh)\
**Post date:** [October 1, 2016, 4:33am UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/4 "2016-10-01T04:33:06Z")

</div>

On the SoftLayer there is an option for selecting a post provisioning script, where you can provide the set of WinRM commands to run after VM provisioned.

---

<div class="post-metadata">

**Author:** ![neal\_pally](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@neal\_pally](https://forum.ansible.com/u/neal_pally)\
**Post date:** [July 17, 2018, 10:51pm UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/5 "2018-07-17T22:51:58Z")

</div>

Hey Jon,

I am able to run script using run once from vmware custom spec, however it prompts for User Access Control(UAC), any ideas on how to get around this?

Neal

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 18, 2018, 8:53am UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/6 "2018-07-18T08:53:45Z")

</div>

I’d imagine running as a local administrator would avoid this.

---

<div class="post-metadata">

**Author:** ![Lee\_Drew](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@Lee\_Drew](https://forum.ansible.com/u/Lee_Drew)\
**Post date:** [July 24, 2018, 8:22pm UTC](https://forum.ansible.com/t/how-to-have-windows-configured-with-ansible-automatically/21041/7 "2018-07-24T20:22:53Z")

</div>

Are your Windows boxes domain joined? If so, you can specify applicable GPO (if required) or just auth to them via kerberos. I auth to our Windows servers via kerberos using an account that has local admin rights on every server - I don’t run any scripts or make any changes on the Windows hosts before initiating connections to them.
