If you for example don’t have System Center Virtual Machine Manager or another tool to create Virtual Machine Templates and automate the deployment, you can also do this using Sysprep, PowerShell and an unattend.xml file to automate or simplify the Virtual Machine creation process. In other blog posts I already wrote how you can sysprep Virtual Machines or how you can create Hyper-V Virtual Machines using PowerShell. In this post I will show you how you can add an unattend.xml file to your VHD or VHDX so your virtual machine gets some default settings like regional information.
Here we have a basic unattend.xml file. If you want to enhance it, or create your own, you can also use the Windows ADK.
To use this unattend.xml you first have to sysprep a virtual machine and create a sysprep VHD file. After that you can mount the VHDX file and insert the unattend.xml file to the VHD. Copy the unattend.xml file to the following location: D:\Windows\Panther (in my case the VHD was mounted as D drive).
You can mount the VHDX using the UI or PowerShell:
Mount-VHD .\VHDFile.vhdx Copy-Item .\unattend.xml -destination D:\Windows\Panther\ Dismount-VHD .\VHDFile.vhdx
There are more paths as well. You can check out the Windows Setup Automation Overview on TechNet where you can see all the possible paths to place the unattend.xml file.Tags: Hyper-V, Microsoft, PowerShell, unattend.xml, VHD, VHDX, Virtual Machine, Virtualization, Windows, Windows 10, Windows Server, Windows Server 2016 Last modified: January 7, 2019