Latest update

6/recent/ticker-posts

Create Unattend Answer File for Windows Server 2019 Automated Packer Installation

Recently, I have been working a lot with Packer installations in the home lab to configure automated builds of Server operating systems to have always “up-to-date” copies of Windows Server templates so that you shortcut all the time needed to build up a Windows Server operating system, patch the OS, and then install your applications. With Packer, you can perform all of these tasks and have these templates on hand and ready to go at a moment’s notice. One of the first things you will need to do is either create or download a Windows Server unattend answer file. In this post, we will take a look at what an unattend answer file is as well as resources that can be used to either create unattend answer file for Windows Server 2019 automated packer installation or download one.

What is a Windows Server Answer File?

The answer file is a special file that is in an XML format that contains setting definitions and values for the configuration settings you want to automated during the installation of a Windows Server operating system installation. The configuration options include how to partition disks, where to find the Windows image to be installed, product keys to apply, and other commands you would like to run. Basically, you can place in the answer file all the configuration that you can carry out manually using the GUI Windows Server operating system installation in the Windows PE environment and then in the “out of the box” installation setup wizard.
There are (7) components in the unattend answer file that can be customized to provide “answers” to the configuration in question. These seven components provide the configuration for the various parts of the installation and configuration of Windows Server. The are the following:
  • windowsPE
  • offlineServicing
  • generalize
  • specialize
  • auditSystem
  • auditUser
  • oobeSystem
The-components-of-the-Unattend-answer-file-found-in-Windows-Server-2019 Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
The components of the Unattend answer file found in Windows Server 2019

Create Unattend Answer File for Windows Server 2019 Automated Packer Installation

The Unattend.xml answer file is typically the name most use for the special answer file using for unattended installations of Windows Server. However, you can call the file anything you would like. While you could simply use Notepad or another text editor to create an Unattend.xml file from scratch, being as this is an XML file that is very sensitive to syntax and the proper tags being used, etc, doing it that way would be fairly difficult.
Microsoft has provided a tool that is very helpful in creating these unattend answer files for unattended installations of Windows Server and Windows 10 operating systems. The tool is part of the Windows Assessment and Deployment Kit. It is called the Windows System Image Manager.
The Windows System Image Manager or Windows SIM provides an easy way to create unattend answer files using this GUI tool and the component sections described above as part of the answer file. You can use the GUI tool to create the “answers” the configuration questions presented in the GUI. Then once finished, the Windows SIM creates the file in the correct format/syntax.

Installing Windows System Image Manager

To install the Windows System Image Manager, you need to download the Windows Assessment and Deployment Kit found here:
https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install
I have found to avoid issues with images and catalog creation, it is best to use the version of the Windows ADK that corresponds to the version of the operating system you are working with.
After downloading the Windows Assessment and Deployment Kit, run the installer.
Beginning-the-Windows-Assessment-and-Deployment-Kit-installation-1 Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Beginning the Windows Assessment and Deployment Kit installation
Privacy-configuration-during-the-WADK-installation Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Privacy configuration during the WADK installation
Accept-the-Windows-Assessment-and-Deployment-Kit-EULA Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Accept the Windows Assessment and Deployment Kit EULA
On the features you want to install page, the only component that we need to install for the Windows System Image Manager is the Deployment Tools.
Installing-the-Deployment-Tools-from-the-Windows-Assessment-and-Deployment-Kit Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Installing the Deployment Tools from the Windows Assessment and Deployment Kit
The installation finishes successfully for the Windows SIM.
Installation-of-Windows-Assessment-and-Deployment-Kit-completed-successfully Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Installation of Windows Assessment and Deployment Kit completed successfully
After installation, if you are struggling to find the program shortcut for the Windows ADK and specifically Windows System Image Manager, the program group is found under Windows Kits under the Windows 10 Start Menu. Launch the Windows System Image Manager.
After-launching-Windows-System-Image-Manager-interface Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
After launching Windows System Image Manager interface
Before creating an answer file for a particular unattended installation of Windows Server 2019, you need to download the Windows Server 2019 media. After downloading the media, copy the install.wim file from the media to a writeable folder on your workstation. We will use the install.wim file to create the catalog file which is required for creating a new answer file. The catalog file is created after all the files are scanned from the .wim file.
Copy-the-install.wim-to-a-writeable-folder-on-your-workstation-for-the-Windows-System-Image-Manager Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Copy the install.wim to a writeable folder on your workstation for the Windows System Image Manager
After you have copied the Windows Image from the media to the location you want to work with it, you right click the Select a Windows image and choose Select Windows Image to browse to the image file.
Select-the-install.wim-file-you-copied-in-the-select-Windows-image-dialog-box Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Select the install.wim file you copied in the select Windows image dialog box
As you know the installation media has the images for the various versions of Windows Server including Standard, Datacenter, and Core. Here I am choosing the Server Standard image.
Select-the-Windows-Image-you-want-to-work-with-in-creating-the-new-Answer-file Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Select the Windows Image you want to work with in creating the new Answer file
Once you choose an image, a catalog file will need to be created to work with the image and create the Answer File. You will see the message displayed about creating a catalog file for the Image. Click Yes.
Cannot-find-the-catalog-file-prompted-to-create-one Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Cannot find the catalog file prompted to create one
Once the Image is mounted and the catalog file is created, right click the Create or open an answer file to create a new Answer file.
Windows-Image-is-mounted-and-catalog-file-is-created-ready-to-create-answer-file Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Windows Image is mounted and catalog file is created ready to create answer file
Select to create New Answer File.
Create-a-new-answer-file-for-use-with-Windows-Server-2019 Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Create a new answer file for use with Windows Server 2019
As shown the Answer File is created with the (7) components for customization listed for the various configuration passes.
New-Answer-File-created-with-the-various-components-listed-for-customizing Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
New Answer File created with the various components listed for customizing
To add custom configuration, right-click the various components and under the Windows Image and Add Settings to Pass for adding the configuration you want to be passed along in the Answer File.
Adding-settings-passes-to-various-components-of-the-answer-file Create Unattend Answer File for Windows Server 2019 Automated Packer Installation
Adding settings passes to various components of the answer file
After adding your configuration to the various passes and components. Simply select File > Save Answer File to save the file to disk so you can use it with your Packer build.
Below is an example unattend answer file for Windows Server 2019 created for use with Packer.
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <unattend xmlns="urn:schemas-microsoft-com:unattend">
  3. <settings pass="windowsPE">
  4. <component name="Microsoft-Windows-International-Core-WinPE" 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">
  5. <SetupUILanguage>
  6. <UILanguage>en-US</UILanguage>
  7. </SetupUILanguage>
  8. <InputLocale>en-US</InputLocale>
  9. <SystemLocale>en-US</SystemLocale>
  10. <UILanguage>en-US</UILanguage>
  11. <UserLocale>en-US</UserLocale>
  12. </component>
  13. <component name="Microsoft-Windows-Setup" 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">
  14. <DiskConfiguration>
  15. <Disk wcm:action="add">
  16. <CreatePartitions>
  17. <CreatePartition wcm:action="add">
  18. <Order>1</Order>
  19. <Size>250</Size>
  20. <Type>Primary</Type>
  21. </CreatePartition>
  22. <CreatePartition wcm:action="add">
  23. <Order>2</Order>
  24. <Extend>true</Extend>
  25. <Type>Primary</Type>
  26. </CreatePartition>
  27. </CreatePartitions>
  28. <ModifyPartitions>
  29. <ModifyPartition wcm:action="add">
  30. <Order>1</Order>
  31. <PartitionID>1</PartitionID>
  32. <Format>NTFS</Format>
  33. <Label>Boot</Label>
  34. <Active>true</Active>
  35. </ModifyPartition>
  36. <ModifyPartition wcm:action="add">
  37. <Order>2</Order>
  38. <PartitionID>2</PartitionID>
  39. <Format>NTFS</Format>
  40. <Label>System</Label>
  41. </ModifyPartition>
  42. </ModifyPartitions>
  43. <DiskID>0</DiskID>
  44. <WillWipeDisk>true</WillWipeDisk>
  45. </Disk>
  46. </DiskConfiguration>
  47. <ImageInstall>
  48. <OSImage>
  49. <InstallFrom>
  50. <MetaData wcm:action="add">
  51. <Key>/IMAGE/NAME</Key>
  52. <Value>Windows Server 2019 SERVERSTANDARD</Value>
  53. </MetaData>
  54. </InstallFrom>
  55. <InstallTo>
  56. <DiskID>0</DiskID>
  57. <PartitionID>2</PartitionID>
  58. </InstallTo>
  59. <WillShowUI>OnError</WillShowUI>
  60. <InstallToAvailablePartition>false</InstallToAvailablePartition>
  61. </OSImage>
  62. </ImageInstall>
  63. <UserData>
  64. <AcceptEula>true</AcceptEula>
  65. <ProductKey>
  66. <Key>11111-22222-33333-44444-55555</Key>
  67. <WillShowUI>Never</WillShowUI>
  68. </ProductKey>
  69. </UserData>
  70. </component>
  71. </settings>
  72. <settings pass="specialize">
  73. <component name="Microsoft-Windows-Shell-Setup" 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">
  74. <TimeZone>Central Standard Time</TimeZone>
  75. </component>
  76. <component name="Microsoft-Windows-Deployment" 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">
  77. <RunSynchronous>
  78. <RunSynchronousCommand wcm:action="add">
  79. <Path>a:\vmtools.cmd</Path>
  80. <Order>1</Order>
  81. <WillReboot>Always</WillReboot>
  82. </RunSynchronousCommand>
  83. </RunSynchronous>
  84. </component>
  85. </settings>
  86. <settings pass="oobeSystem">
  87. <component name="Microsoft-Windows-Shell-Setup" 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">
  88. <AutoLogon>
  89. <Password>
  90. <Value>"your password"</Value>
  91. <PlainText>true</PlainText>
  92. </Password>
  93. <LogonCount>2</LogonCount>
  94. <Username>Administrator</Username>
  95. <Enabled>true</Enabled>
  96. </AutoLogon>
  97. <FirstLogonCommands>
  98. <SynchronousCommand wcm:action="add">
  99. <Order>1</Order>
  100. <!-- Enable WinRM service -->
  101. <CommandLine>powershell -ExecutionPolicy Bypass -File a:\configureVM.ps1</CommandLine>
  102. <RequiresUserInput>true</RequiresUserInput>
  103. </SynchronousCommand>
  104. </FirstLogonCommands>
  105. <UserAccounts>
  106. <AdministratorPassword>
  107. <Value>"your password"</Value>
  108. <PlainText>true</PlainText>
  109. </AdministratorPassword>
  110. </UserAccounts>
  111. </component>
  112. </settings>
  113. <cpi:offlineImage cpi:source="wim:c:/users/administrator/desktop/win2019/install.wim#Windows Server 2019 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
  114. </unattend>

Windows Server 2019 Automated Answer File Resources

You can find just about anything you want to find with answer files and customized files that others have created. Below are a few of the really good resources I have used for creating unattend answer files either in Github resources or blog posts.

Wrapping Up

The process to Create Unattend Answer File for Windows Server 2019 Automated Packer Installation using the Windows System Image Manager is extremely easy and effective. It takes all the heavy lifting out of the process. I have found it easier to create a file from scratch than trying to hack others files if the customization contains a great deal of customized entries. Generally, it is easy to run into syntax errors and other problems trying to paste in code. Windows System Image Manager helps with this. Unattended installations are a great way to start delving into automation and build process that lend themselves to automating your provisioning process. Stay tuned for more Packer goodness coming soon.

Post a Comment

0 Comments