Deployment–The PDT VM Creator

I introduced the PowerShell Deployment Toolkit, or PDT, in a previous post.  As I mentioned in that post, PDT requires that the servers that System Center will be deployed to are already running, members of an Active Directory domain, and you have administrator permissions to those servers.  PDT includes a script to help create Hyper-V VMs for this purpose – VMCreator.ps1.  This post explains how to use and customize VMCreator.ps1.

VMCreator.ps1 will create any number of VMs for you on one or more standalone Hyper-V hosts.  Note that the current version will not create highly available VMs on a Hyper-V cluster.  VMCreator.ps1 takes input from the <VMs> section of the variable.xml file in the same folder.  Under <VMs> there are two required entries – <Count> specifies how many VMs to create, and <Default> specifies the default settings for each VM to be created.  Most of the entries under <Default> are fairly self-explanatory, but there are a few that need a little more detail:

  • <VMName> lists a prefix and a starting sequence number.  In the sample variable.xml file with PDT, it uses “Server” as the prefix and starts the sequence at 11.  So VMCreator.ps1 will create VMs called Server11, Server12, Server13, etc.
  • The <NetworkAdapter> section has two optional settings – <MAC> and <IP>.  These are used if you want to specify static MACs and IPv4 addresses – if you want those to be dynamic, just delete those sections.
  • <OSDisk> specifies the parent VHD for the operating system drive.  This must be a sysprepped VHD for the operating system version you wish to install, and must be a single partition VHD.  The easiest way to create this parent disk is to use Convert-WindowsImage.ps1 and just create the VHD from the Windows Server media.
  • <PagefileDisk> is optional – but allows you to specify a VHD that will be used as the D: drive.  In my lab, I always move the pagefile to the D: drive to allow me to wipe it whenever it gets bloated.  If you don’t want to do this, just delete this section also.
  • <DataDisks> is also optional – so you can create disks other than the operating system drive.  If you want data disks of different sizes, you can use multiple <DataDisks> sections, or if you just want the operating system drive, you can delete the section.
  • Under <JoinDomain>, <OrganizationalUnit> is also optional.  If you want to use the default AD container for new computer accounts, just delete the <OrganizationalUnit> section.

If you want specific settings other than the defaults for individual VMs, such as creating specific VMs on a Hyper-V host other than the default, you can add a <VM> section at the same level as <Default>, and specify individual settings in that section.  The section header must specify the VM number.  All settings not specified in the <VM> section will still be used from <Default>.  For example:

<VM Count=”1″>
< /VM>

Finally, VMCreator.ps1 must be run from a Windows Server 2012 system that has the Hyper-V PowerShell module installed.