# how should I connect to windows clients with dhcp addresses?

**URL:** <https://forum.ansible.com/t/how-should-i-connect-to-windows-clients-with-dhcp-addresses/29932>\
**Category:** Ansible Developer\
**Tags:** windows\
**Created:** [March 20, 2019, 9:55pm UTC](https://forum.ansible.com/t/how-should-i-connect-to-windows-clients-with-dhcp-addresses/29932 "2019-03-20T21:55:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_V](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_V](https://forum.ansible.com/u/Mike_V)\
**Post date:** [March 20, 2019, 9:55pm UTC](https://forum.ansible.com/t/how-should-i-connect-to-windows-clients-with-dhcp-addresses/29932/1 "2019-03-20T21:55:12Z")

</div>

Hi,  
I want to add windows clients to an Active Directory domain. The clients are getting IP addresses from dhcp and they are not in DNS. Should I write a playbook to query the dhcp server with the known hostnames to generate an inventory file, and then write another playbook to add them to the domain? Any better approaches?

---

<div class="post-metadata">

**Author:** ![dnsbob](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dnsbob](https://forum.ansible.com/u/dnsbob)\
**Post date:** [March 21, 2019, 2:28pm UTC](https://forum.ansible.com/t/how-should-i-connect-to-windows-clients-with-dhcp-addresses/29932/2 "2019-03-21T14:28:13Z")

</div>

If Active Directory and the clients are configured properly, the Active Directory DNS should be updated automatically. I do not know the details.

---

<div class="post-metadata">

**Author:** ![Mike\_V](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_V](https://forum.ansible.com/u/Mike_V)\
**Post date:** [March 21, 2019, 3:24pm UTC](https://forum.ansible.com/t/how-should-i-connect-to-windows-clients-with-dhcp-addresses/29932/3 "2019-03-21T15:24:08Z")

</div>

Thanks for the reply. This is for machines on the network that are NOT joined to the domain yet, so they do not have a DNS entry.  
I took the approach of running a win\_shell task against the dhcp server and then using in-memory inventory with add\_host to further configure the hosts.  
I think a better approach might be to use custom inventory script to query the windows dhcp server instead of using in-memory invenotry. Anybody have experience writing custom inventory script querying a windows box?
