Mastering Windows Server 2016 Hyper-V

(Romina) #1

unattend.xml file is by using the Windows System Image Manager (SIM) that is part
of the Windows Assessment and Deployment Kit (Windows ADK). The following XML
sets the time zone of the OS to Central Time (which could also be performed using
tzutil /s “Central Standard Time” remotely via Enter-PSSession post deployment):


<?xml version="1.0" encoding="utf-8"?>




processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Central Standard Time



You may wonder how the customization of the OS is performed when a custom
unattend.xml file can be passed. The New-NanoServerImage cmdlet works by using the
unattended application feature of Deployment Image Servicing and Management
(DISM) that enables the offline application of an unattended answer file to an image
directly, without requiring the unattend.xml to be passed during the specialization
phase. If you look at the Nano Server image-generator script, you will see the DISM
line that uses the /Apply-Unattend parameter, which is how the configuration is
applied. The great thing about this approach is it that it allows you to add your own
unattend.xml file for additional configurations required during specialization.


The following PowerShell creates a new Nano Server VHD file that can be used with
VMs running on Hyper-V. The content of the NanoServer\NanoServerImageGenerator
folder on the Windows Server 2016 media has been copied to the D:\NanoBuild folder
in this example. In this example, the execution is performed on a member of the
domain to which the Nano instance is being joined, enabling a simple join action. It is
also possible, however, to join a domain when the creating environment is not part of
the same domain, and this is fully documented in the Microsoft article mentioned at
the start of this section (https://technet.microsoft.com/en-us/library/mt126167.aspx).


#Load the PowerShell module
Import-Module 'D:\NanoBuild\NanoServerImageGenerator.psm1 `


#Setup variables to store the local administrator password and location
#for target VHD to be created
$adminPass = ConvertTo-SecureString "Pa55word" -AsPlainText -Force
$NanoVHDPath = ".\NanoServerVM.vhd"


#Create the image
New-NanoServerImage -MediaPath 'S:\W2016\Expanded' -BasePath .\Base -TargetPath $NanoVHDPath -ComputerName NanoVM
-DeploymentType Guest -Edition Standard -Storage -Defender -EnableRemoteManagementPort
-Package Microsoft-NanoServer-DSC-Package `

Free download pdf