Ansible Hyper-V inventory module

I looked but could not find a module for Hyper-V. It would be useful to build a dynamic inventory from a Hyper-V host (Windows).
The manual way would be to do something with Powershell and write an inventory file for Ansible. I wonder if someone already approached this?

This is not to deploy VMs, just index about 6 hosts with each around 50 VMs give or take.

1 Like

Iā€™m not sure that anyone has done this, but it could be done similarly to how the inventory plugin works. Alternatively, you could use the script module to run powershell script over a PSSession to your hyper-v host, and return inventory json that way.

ansible.builtin.script inventory ā€“ Executes an inventory script that returns JSON ā€” Ansible Documentation