With my PowerCLI function New-MDTVM, you can easily deploy VMware virtual machines (VMs) with the Microsoft Deployment Toolkit (MDT).

If you are managing Windows servers, chances are you have a mix of physical and virtual servers in your data center. While VMware provides a method to create VMs from templates to simplify server deployments, this method obviously does not work for deploying physical servers. Fortunately, you can use MDT to deploy a physical or virtual server, which provides one solution for configuring on-premises server deployment tasks.

For new servers to use MDT, they need to boot to Windows PE using the preboot execution environment (PXE). We most commonly do this with Windows Deployment Services (WDS) or by booting directly to CD/ISO Lite Touch media, which circumvents WDS. For deploying new VMs, I prefer to attach the Lite Touch ISO file to a VM. Using this method, I do not have to depend on PXE. In addition, I can automate creating a new VMware virtual machine by just running a PowerCLI cmdlet.

Configuring MDT ^

One of the exceptional features of MDT is that you can automate the wizard to the point where there is no need for user interaction. This is ideal for server deployments because depending on the size of your environment, automation is essential for reducing overhead. You can easily deploy multiple VMs simultaneously. I will not elaborate on this process as there are many tutorials online, but I highly recommend you take this approach.

Copy the Lite Touch ISO to a data store with PowerCLI ^

After setting up and configuring MDT to automate the deployment wizard, the next step is to copy over the Lite Touch ISO to a data store in your vSphere environment.

To copy the ISO to a data store, we can use the Copy-DataStoreItem cmdlet in PowerCLI. In the example below we are copying the Lite Touch ISO file from the "MDTServer" MDT share to a data store called "testvmstore." Note that connecting to vCenter with PowerCLI creates a PS drive (vmstore) that provides access to all data stores via the VMware data store PowerShell provider.

Create and deploy a new virtual machine with PowerCLI ^

Now that we've copied the Lite Touch ISO, we can create a new VM with PowerCLI. We can then attach the ISO to the new VM, which will boot to a CD by default before the hard drive. Attaching the ISO to the virtual CD drive and starting the VM is all we need to begin the imaging process.

I created a simple function for this, New-MDTVM, to automate the attachment and detachment of the Lite Touch ISO. To do this, the function uses the PowerCLI cmdlet Set-CDDrive as well as the New-VM cmdlet to create the new VMware virtual machine in vSphere.

The Set-CDDrive cmdlet specifies the data store location of the Lite Touch ISO with the -IsoPath parameter and ensures the ISO is attached upon boot with -StartConnected:$true. Notice that with New-VM, you can set many features of the VM, such as guest OS, VMhost, disk size, memory, and network.

New-MDTVM function example ^

In this example, I am going to create a new VM called "testvm," specifying the Lite Touch ISO location, memory amount, computer name, and vCenter hostname. Note the other parameters I will leave as their default values specified in the function.

If we open the VM console after running New-MDTVM, we see that MDT has begun the imaging process and is installing the operating system.

Deploying an OS with the MDT

Deploying an OS with the MDT

Read 4sysops without ads by becoming a member!

Your question was not answered? Ask in the forum!

5+

Users who have LIKED this post:

  • avatar
  • avatar
  • avatar
Share
5 Comments
  1. Hi Dan,

    why not simply use standard vSphere approach and deploy VMs from previously build/customized golden image and customizing it via OS Customization manager?

    Seems much more simpler than this.

    Whats the difference?

    Leos

    1+

    • Joe Bembry 3 years ago

      Hey Leos,

      The short answer is that MDT allows for more customization to your golden images. I don't think the idea for this is the deployment of golden images, but rather the automatic creation of fully patched golden images that you can use for your vsphere templates. The MDT approach also allows for automation of all the OS features and additional software, etc to be included. We use a similar approach via Hyper-V.

      Joe

      2+

  2. Thanks

    1+

  3. Nice post, Dan!

    Did you try this in an Active Directory environment? If so, how have you solve the domain join?
    Offline via file? I meet the situation that I can't login because firewall ports are closed ...

    1+

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account