Automating VM creation with HyperV

Hi All,

My goal has been to automate the creation of Windows (VM) servers on HyperV. I want to be able to create test scenarios with multiple servers with very few manual steps. I am able to use “chef generate” and “kitchen converge” to setup a basic Windows VM, but there are still too many manual steps.

I am currently trying to customize the name of the VM and the hostname, but I do not know the most efficient way to do this. It seems to me that I ought to be able to specify these in the kitchen.yml file or one of the .rb files, but I cannot find an example how to do this.

Alternatively, I can try running ‘kitchen converge’ from a PowerShell script and set at least the VM name later in that script, but I have yet to figure out how to get ‘kitchen converge’ to run in a script.

I am not yet invested in a particular strategy, because I just do not know enough. Any hints would be appreciated!


I just had a quick search using knife supermarket search hyper - This didn’t return any recipes or the like. So what I would do is use the powershell_script resource as defined in the chef docs found here. Using this resource, you can then use the methods described here and here, using ruby variables to ensure that the machine names etc are dynamic.