In This Article
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.
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?
- 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).
- 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.
- HPE Intelligent Provisioning: The 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.
- 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.
- 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
- 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.
- 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
- 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
- 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.
# Automate Windows Server deployment on Physical machine without WDS # Author - Charbel Nemnom # https://charbelnemnom.com # Date - October 25, 2017 # Version 2.0 # system: BIOS Mode # File: WindowsServer-BIOSDeployment.ps1 $script =@" select disk 5 clean REM == 1. Windows System partition =============== create partition primary size=350 active format quick fs=ntfs label="System" assign letter="T" REM == 2. Windows partition ======================== create partition primary format quick fs=ntfs label="Windows" assign letter="P" exit "@ $script | diskpart # Copy Windows Server VHDX file Copy-Item S:\WindowsServer_DatacenterCore_1709.vhdx P:\WindowsServer_DatacenterCore_1709.vhdx # Find out how many physical volumes exist before we do any work with the VHDX [array]$temp = "list volume" | diskpart $script = @" select vdisk file=P:\WindowsServer_DatacenterCore_1709.vhdx attach vdisk exit "@ $script | diskpart # This determines which volume number the VHDX was mounted to. It then assigns the letter V $vhdVol = ($temp.length-12) + 1 $script = @" select volume $vhdVol assign letter=V exit "@ $script | diskpart # Bcdboot command write both UEFI and BIOS boot information to the system partition on the physical drive bcdboot V:\Windows /s T: /f All # Remove the letter T off the system partition. $script = @" select disk 0 select partition 1 remove letter=T exit "@ $script | diskpart
- Share Directory: Here is the sample shared directory structure that I am using for this deployment after copying the required files.
- 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.
- 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.
PowerShell Net use S: \\172.16.20.35\TempPE /User:admin Auto@rtin Set-ExecutionPolicy Bypass -Force S:\WindowsServer-BIOSDeployment.ps1 Restart-Computer
- Deploying in Action: The deployment will kick in and utilize the available network bandwidth. In just couple of minutes, the deployment will be completed.
- Once the deployment is done, you need to restart the computer. The system will restart couple of times before you can start using it.
- Finally, you will be asked to change the Administrator password and you are good to go…
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!