# Provision Hyper-V virtual machines thru Ansible

**URL:** <https://forum.ansible.com/t/provision-hyper-v-virtual-machines-thru-ansible/30773>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [July 12, 2019, 3:58pm UTC](https://forum.ansible.com/t/provision-hyper-v-virtual-machines-thru-ansible/30773 "2019-07-12T15:58:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neeraj\_Shah](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@Neeraj\_Shah](https://forum.ansible.com/u/Neeraj_Shah)\
**Post date:** [July 12, 2019, 3:58pm UTC](https://forum.ansible.com/t/provision-hyper-v-virtual-machines-thru-ansible/30773/1 "2019-07-12T15:58:06Z")

</div>

Hello All,

I am newbie to Ansible.

Can someone pls point me to resources or post some playbook code that deploys VM’s on a Hyper-V 2012 or 2016 server ? Alternatively, lets say if i have a golden image of a VM created ( in \*.vhd or \*.vhdx format), how can i deploy this image to multiple hosts using Ansible?  
I have looked online and see there is stuff for Vmware but couldnt find much help for Hyper-V

thanks

---

<div class="post-metadata">

**Author:** ![Jaya\_Nehru\_Kumar](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@Jaya\_Nehru\_Kumar](https://forum.ansible.com/u/Jaya_Nehru_Kumar)\
**Post date:** [July 14, 2019, 9:48am UTC](https://forum.ansible.com/t/provision-hyper-v-virtual-machines-thru-ansible/30773/2 "2019-07-14T09:48:31Z")

</div>

Hi Neeraj ,

As of now , there is no ansible native modules available to support this.  
steps involved to get this done.

1. create one windows host
2. connect to this host using ansible and invoke powerhsell module for deploying resources in hyper-v  
[https://docs.microsoft.com/en-us/powershell/module/hyper-v/new-vm?view=win10-ps](https://docs.microsoft.com/en-us/powershell/module/hyper-v/new-vm?view=win10-ps)

---

<div class="post-metadata">

**Author:** ![Neeraj\_Shah](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@Neeraj\_Shah](https://forum.ansible.com/u/Neeraj_Shah)\
**Post date:** [July 15, 2019, 3:20pm UTC](https://forum.ansible.com/t/provision-hyper-v-virtual-machines-thru-ansible/30773/3 "2019-07-15T15:20:24Z")

</div>

Thanks Jaya. But how do you run those hyper-v cmdlets using playbooks ? Do i need to use win\_shell module ?
