Back to Basics – Using an AutoUnattend.xml file to Automate Windows 11 Setup from Media

Occasionally, I receive questions on how to use an AutoUnattend.xml file to automate the Windows 11 Setup. Here is a blog post on how to do just that, and as a bonus, I added instructions on how to stage PowerShell scripts and a Provisioning Package as part of the process. For example, to bulk enroll a device into Microsoft Intune.

Real World Note: In general, you are better off generating media from a real deployment solution like MDT, ConfigMgr (SCCM), or a third-party. These solutions offer way more features than the native Windows setup, but if you need something super-simple, or simply want to learn a bit about how Windows setup works, keep on reading 🙂

Background – A Little History of Windows Unattended Setup

The idea of automating Windows installations has been around for decades. In the early Windows NT and Windows 2000 days, admins used unattend.txt files with the Setup Manager tool to answer prompts automatically. These were plain INI-style text files: straightforward, but limited in flexibility.

With Windows Vista (and Server 2008), Microsoft overhauled the setup process. They introduced a new XML-based schema called Unattend.xml, built to handle the more modular architecture of the Windows Imaging (WIM) format. Instead of scripting every step, you could now describe settings in structured passes, such as windowsPE, specialize, and oobeSystem. This allowed Setup to apply settings at the right stage of installation.

As deployments became more advanced, Microsoft created the Windows System Image Manager (WSIM) — part of the Windows Automated Installation Kit (WAIK), later replaced by the Windows Assessment and Deployment Kit (Windows ADK). WSIM lets you open a WIM image, browse all configurable components, and generate valid unattend files without hand-editing XML.

AutoUnattend.xml vs Unattend.xml

There are two main flavors of these files:

  • Unattend.xml – placed in C:\Windows\Panther or supplied via tools like MDT or ConfigMgr. Setup reads it during image deployment.
  • AutoUnattend.xml – specially named so that Setup.exe looks for it automatically on removable media (USB, DVD, ISO root). This is what makes it so handy for automating installs from bootable media: you don’t need a management infrastructure, just the XML in the right spot.

The $OEM$ Folder Structure

Another long-standing piece of Windows setup automation is the $OEM$ folder structure. This convention dates back to the unattend.txt days and continues to work with Unattend.xml today. When placed alongside your installation media, a $OEM$ folder lets you inject extra files, scripts, and drivers directly into the Windows installation.

This makes it easy to stage custom PowerShell scripts, configuration files, or branding assets that can then be executed later via FirstLogonCommands or SetupComplete.cmd. Here are a few examples:

  • Files in \$OEM$\$1\ will be copied to the root of the system drive, C:\.
  • Files in \$OEM$\$1\subfolder, such as \$OEM$\$1\Drivers, will be copied to C:\Drivers.
  • Files in \$OEM$\$$\ will be copied to C:\Windows.

Generating an Automated Windows 11 Media

Creating an Automated Windows 11 Media is straightforward and easy to automate, but a few steps are required. The steps below assume that you have downloaded a Windows 11 media (ISO) from Microsoft:

Note: Any provisioning package added to the C:\Windows\Provisioning\Packages folder will be automatically provisioned. This folder is sometimes referred to as the auto provisioning folder, but it's not particularly well documented. Another option is to have SetupComplete.cmd install it, or stage it in WinPE via a RunSynchronous command.

  1. Mount the Windows 11 media and copy its content to a temporary folder, like C:\Temp.
  2. Copy your AutoUnattend.xml file to the root of the temporary folder.
  3. Create the $OEM$ structure in the Sources subfolder, for example:
    • $OEM$\$$\Setup\Scripts to add scripts to C:\Windows\Setup\Scripts
    • $OEM$\$$\Provisioning\Packages to add scripts to C:\Windows\Provisioning\Packages
  4. Generate a new bootable ISO using oscdimg.exe from Windows ADK.
Bulkr enrollment package added to the $OEM$ folder structure

Generating Media via PowerShell – This is the Way

Below you find a PowerShell script that does the preceding section steps, as well as a sample AutoUnattend.xml for Windows 11 Enterprise (the Script is named: New-Windows11MediaWithAutoUnattendAndEnrollmentPackage.ps1)

https://github.com/DeploymentResearch/DRFiles/tree/master/Scripts/BulkEnrollment

Note: The script assumes that you have Windows ADK for Windows 11 installed, and the AutoUnattend.xml is purposely configured to stop at the disk selection. For complete automation, change the InstallTo\WillShowUI setting from Always to OnError on line 71.

Windows 11 Setup purposely stopped at the disk selection screen.
Machine enrolled via bulk enrollment provisioning package

Resources

To generate a provisioning package for bulk enrollment, use this excellent post from Michael Niehaus: Simplify the process of generating an AAD bulk enrollment provisioning package

Tip: You will find a slightly modified version of Michael's script here (named Generate-Entra-PPKG.ps1): https://github.com/DeploymentResearch/DRFiles/tree/master/Scripts/BulkEnrollment

If you want to learn how to use a real deployment solution like MDT or ConfigMgr (SCCM) to stage provisioning packages, check out this post: Windows Autopilot Plan B

There is also an excellent online autounattend.xml generator (thank you Tony for mentioning that)
https://schneegans.de/windows/unattend-generator/

About the author

Johan Arwidmark

5 5 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Afraid to Ask
Afraid to Ask
1 year ago

Could any of this be applied to WinRe – so when resetting a PC it would have some files preloaded, or even install the PPKG rather than going through OOBE?


>