How To Deploy Windows Server 2016 from VHDX on SD Cards with #PowerShell and WinPE #WindowsServer #HyperV

Introduction

If you are regularly deploying Windows operating systems, the combination of Microsoft WinPE and Windows PowerShell tools work together to speed up the deployment of Windows Server. There are also other tools of course you can use such as Microsoft Deployment Toolkit (MDT), System Center Virtual Machine Manager (SCVMM) or Windows Deployment Services (WDS) to accomplish the same thing. But the purpose of this article is to provide a step-by-step guidance on how to automate and deploy Windows Server 2016 from VHDX and not from ISO or WIM file. This includes the various operating system installation options, such as Hyper-V Server, Windows Server Standard or Datacenter, Core or Windows Server with Desktop Experience.

As a prerequisite for the remainder of this post, please check my previous article on How To Create a Custom WinPE Boot Image With PowerShell Support.

Scenario

I came across a scenario recently where I want to deploy and validate a new Windows Server insider build version 1709+. The build (media) was provided in VHDX format only and not ISO. And to make things more challenging, my HPE physical machine has an SD card with 32 GB that I use for OS deployment.

Disclaimer: Windows Server has some requirements that SD cards are not able to meet around endurance, performance, and capacity. Thus, deploying Windows Server on SD cards is NOT supported by Microsoft. However, I have been deploying Windows Server Hyper-V on SD cards for quite some time now and it’s working well for me despite slow performance in booting.

So what are the options that we have to deploy Windows Server from VHDX on SD cards?

  1. Boot from VHDX: Unfortunately, this option is not viable to us since there is not enough disk space on the SD card for dual boot. The other disks in the system are used for Storage Spaces Direct (S2D).
  2. Convert VHDX to WIM file: You can use the following script to Convert VHD(X) files to *.WIM so you can deploy them with WDS. Unfortunately, this option is also not viable to us, because Windows cannot be installed on SD cards, so Windows Deployment Services (WDS) deployment option is gone.
  3. HPE Intelligent ProvisioningThe third option is to leverage HPE Intelligent Provisioning. Usually, this option works well when you want to install Windows Server on SD cards, but since the version of Windows Server that I want to deploy is newer than the latest HPE Service Pack for ProLiant (SPP) Version 2017.07.2. HPE Intelligent Provisioning did not recognize that build… Thus I could not move forward and continue. 
  4. Scripting Toolkit Windows PE: HPE Intelligent Provisioning supports booting from Windows PE which you can leverage basic WinPE commands to deploy Windows Server from WIM file. However, this option involve multiple manual steps, and the drawback is, PowerShell is NOT supported either. 
  5. Deploy Windows Server 2016 from VHDX with PowerShell and WinPE: Read On.

Deploying Windows Server From VHDX

As described in my previous post, WinPE is designed to be a very compact image because it is often used for PXE booting a system, and for that purpose it is desired to keep the image as small as possible. As a result, it comes with the basic command-line capabilities. But with the higher speed networks that we have today, you can use WinPE and PowerShell to automate and streamline the process of deploying any Windows operating system. This gives you the ability to create powerful scripts for WinPE to execute for tailoring images.

Prepare the environment

  1. Share: You need to create a directory on a workstation that is accessible by the target machine. This directory includes files that will be used in the tailoring of both the WinPE ISO media and the VHDX target (Windows Server), as well as the automation script (more on that in a bit). Again, this directory structure is the structure used in this example under the following location D:\TempPE. It can be on any volume, and it needs to be shared for network access with specific ACLs.
  2. Local User Account: The above share needs to be accessed by the WinPE automation script in step 4. The simplest way to provide access to the share is to create a local user account on the workstation that has read access to the share. It only needs read access because the complete process is to copy the VHDX file from the share to WinPE which writes it out to the local disk (i.e. SD card). So all modifications of the VHDX file occurs on the targeted server. Once you have successfully created your WinPE media as described here, you can reuse the VHDX file to many different servers simply by modifying a couple variables in the script. In this example, the local user account created is Admin with a password of Auto@rtin
  3. Windows Server VHDX: This is the copy of the VHDX stored in the shared directory above. In this example, the VHDX name is WindowsServer_DatacenterCore_1709.vhdx
  4. Windows Server BIOS Deployment Script: This is the primary script for driving the force behind the automation process. You need to store it in D:\TempPE shared directory. As you can see in the first part of the script, I am selecting disk number 5. This is the SD card number in my system, please make sure to update according to your environment.
  5. Share Directory: Here is the sample shared directory structure that I am using for this deployment after copying the required files.
  6. WinPE ISO Media: You need to create a bootable WinPE ISO image with PowerShell support as described in this post. Once the ISO media is ready, simply mount it to HPE ILO (same will apply to any OEM hardware). I will be using it as virtual drive, and finally reboot the system.
  7. Deploy: In the final step, you need to run the following PowerShell commands from WinPE cmd to initiate the deployment process through the network. Please note that this step can be also automated, please check the Summary section at the end of this post for more details.

  8. Deploying in Action: The deployment will kick in and utilize the available network bandwidth. In just couple of minutes, the deployment will be completed. 
  9. Once the deployment is done, you need to restart the computer. The system will restart couple of times before you can start using it.
  10. Finally, you will be asked to change the Administrator password and you are good to go…

Summary

The above sample shows a fairly minimal solution to automate the deployment of Windows Server from VHDX on SD cards or on any type of disk. You could keep a library of different WinPE images tailored for specific situations. Then you could script the addition of the WinPE ISO to the virtual media of a given server and then initiate a boot. This means that it would be possible to automatically deploy servers on demand without the need to customize or deploy a PXE (WDS) server. If you want to find more on how to automate the deployment further including UEFI systems, please make sure to check my recent published Book Getting Started with Nano Server.

I hope this helps and happy deploying!

Cheers,
-Ch@rbel-

About Charbel Nemnom 325 Articles

Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest’s IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

Leave a Reply