Create Hyper-V VM with DSC

Hello Guys,

I am aware that I can easily create a Hyper-VM with the xHyper-V resource. I am also aware that I can place a configuration file inside windows so Windows can apply the configuration at startup. But can I automate the installation of Windows itself?

So my goal is that I create a HyperV-VM, install the OS automatically and then place a DSC file inside Windows so PowerShell can apply it at startup. The only part I am missing is the automated Windows install.

An Windows unattended installation has been a common thing for many, many years now. This is fully documented on TechNet and many other resources.

When you say…

The only part I am missing is the automated Windows install.

What exactly are you looking for that is not already provided by TechNet resources relative unattended Windows install?

Resources

The Windows Deployment Services (WDS)…
http://technet.microsoft.com/en-us/windowsserver/dd448616.aspx

Windows Deployment Tools Technical Reference

Utilizing Windows Deployment Services in Windows Server 2012 R2…

…functionality is the “supported” method to do automated installations of server and client OS’s in a fully-featured way.

If you don’t want to go that heavyweight you could look at building unattended answer files

that will be used to automate the setup process. This is also a “supported” process, but you’re more “on your own” and it’s not a completely integrated solution. (You sound like you’re comfortable writing code so this might just be up your alley.)

Automatic Installation of Hyper-V Hosts with Windows Server 2012 R2
This is an unattended.xml Installation File for an automatic Installation of Windows Server 2012 R2 Hyper-V Role.The unattended file is generated through Windows System Image Manager. Download the File, place it in a root volume during setup, i.e. a USB Media. It will be detected

The automation of your entire machine could be done with DSC. If you slip the MOF file and the dependant modules directly into the VHDX then on boot DSC will take over and configure everything. You could go one step further and copy the meta mof in the VHDX, on boot the machine should then go to appropriate pull server and pull all the configs and modules it needs. Microsoft has a good article about the process for doing that https://docs.microsoft.com/en-us/powershell/dsc/bootstrapdsc. Hope this helps