Skip to content

Instantly share code, notes, and snippets.

@LordVeovis
Created January 29, 2024 18:21
Show Gist options
  • Save LordVeovis/700a009e583317df3d975ea54e0f27d7 to your computer and use it in GitHub Desktop.
Save LordVeovis/700a009e583317df3d975ea54e0f27d7 to your computer and use it in GitHub Desktop.
Unattended Windows 11 deployment
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing>
<package action="remove">
<assemblyIdentity name="Microsoft-Windows-Kernel-LA57-FoD-Package" version="10.0.22000.1817" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" />
</package>
<package action="remove">
<assemblyIdentity name="Microsoft-Windows-WordPad-FoD-Package" version="10.0.22000.653" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" />
</package>
</servicing>
<settings pass="windowsPE">
<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">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>040c:0000040c</InputLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>fr-FR</UserLocale>
<SystemLocale>fr-FR</SystemLocale>
</component>
<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">
<ComplianceCheck>
<DisplayReport>OnError</DisplayReport>
</ComplianceCheck>
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Size>100</Size>
<Type>EFI</Type>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>MSR</Type>
<Size>16</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>3</Order>
<Type>Primary</Type>
<Size>500</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>4</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<Label>EFI</Label>
<PartitionID>1</PartitionID>
<Format>FAT32</Format>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<PartitionID>3</PartitionID>
<Format>NTFS</Format>
<Label>Recovery</Label>
<Order>3</Order>
<TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<PartitionID>4</PartitionID>
<Format>NTFS</Format>
<Label>OS</Label>
<Order>4</Order>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<PartitionID>2</PartitionID>
<Order>2</Order>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
</DiskConfiguration>
<DynamicUpdate>
<Enable>true</Enable>
</DynamicUpdate>
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>4</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<Key>W269N-WFGWX-YVC9B-4J6C9-T83GX</Key>
</ProductKey>
<AcceptEula>true</AcceptEula>
<Organization>Kveer</Organization>
<FullName>Veovis</FullName>
</UserData>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-IE-InternetExplorer" 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">
<Home_Page>https://www.google.fr</Home_Page>
<DisableFirstRunWizard>true</DisableFirstRunWizard>
<CompanyName>Kveer</CompanyName>
</component>
<component name="Microsoft-Windows-International-Core" 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">
<InputLocale>040c:0000040c</InputLocale>
<SystemLocale>fr-FR</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>fr-FR</UserLocale>
</component>
<component name="Microsoft-Windows-RemoteAssistance-Exe" 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">
<fAllowToGetHelp>false</fAllowToGetHelp>
<fEnableChatControl>false</fEnableChatControl>
<fAllowFullControl>false</fAllowFullControl>
</component>
<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">
<WindowsFeatures>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowInternetExplorer>false</ShowInternetExplorer>
</WindowsFeatures>
<TimeZone>Romance Standard Time</TimeZone>
</component>
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" 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">
<fDenyTSConnections>false</fDenyTSConnections>
</component>
<component name="Microsoft-Windows-SQMApi" processorArchitecture="wow64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CEIPEnabled>0</CEIPEnabled>
</component>
<component name="Microsoft-Windows-Printing-Spooler-Core" 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">
<RemoveMXDW>1</RemoveMXDW>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" 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">
<InputLocale>040c:0000040c</InputLocale>
<SystemLocale>fr-FR</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>fr-FR</UserLocale>
</component>
<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">
<AutoLogon>
<Password>
<Value>YQB6AGUAcgBQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<Enabled>true</Enabled>
<LogonCount>5</LogonCount>
<Username>admin</Username>
</AutoLogon>
<DesktopOptimization>
<ShowWindowsStoreAppsOnTaskbar>false</ShowWindowsStoreAppsOnTaskbar>
<WindowsSpotlightTheme>true</WindowsSpotlightTheme>
<GoToDesktopOnSignIn>true</GoToDesktopOnSignIn>
</DesktopOptimization>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<ProtectYourPC>3</ProtectYourPC>
<UnattendEnableRetailDemo>false</UnattendEnableRetailDemo>
</OOBE>
<Themes>
<SystemUsesLightTheme>false</SystemUsesLightTheme>
<WindowsSpotlight>true</WindowsSpotlight>
<UWPAppsUseLightTheme>false</UWPAppsUseLightTheme>
</Themes>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>YQB6AGUAcgBQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<DisplayName>Local admin account</DisplayName>
<Group>Administrators</Group>
<Name>admin</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<WindowsFeatures>
<ShowInternetExplorer>false</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
</WindowsFeatures>
<RegisteredOrganization>Kveer</RegisteredOrganization>
<RegisteredOwner>Veovis</RegisteredOwner>
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:e:/windows11/iso/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
#Requires -Modules Hyper-V
$_root = "E:\windows11"
$iso = ".\output\windows11.iso"
$vmName = 'win11'
$swName = 'Eth Switch'
$FunctionsToExport = @()
function Remove-TestVM {
param (
[Parameter(Mandatory)]
[string]$VMName
)
$vm = Get-VM -Name $VMName
if ($null -ne $vm) {
Stop-VM -VMName $VMName -TurnOff -Force
# merging disks
do {
$s = (Get-VM $VMName).OperationalStatus
sleep 5
} until ($s.Count -eq 1 -and $s[0] -eq 'Ok')
$hd = Get-VMHardDiskDrive -VMName $VMName
$hdpath = $hd.Path
Remove-VMHardDiskDrive $hd
Remove-Item $hdpath
Remove-VM -Name $VMName -Force
}
}
function Update-TestISO {
param (
[Parameter(Mandatory)]
[string]$UnattendFile,
[Parameter(Mandatory)]
[string]$WindowsSourceRoot,
[Parameter(Mandatory)]
[string]$IsoDest,
[bool]$ArchiveUnattendFile = $true
)
$_oscdimg = "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe"
$efiBin = [System.IO.Path]::Combine($WindowsSourceRoot, 'efi\microsoft\boot\efisys_noprompt.bin')
$targetUnattendFile = [System.IO.Path]::Combine($WindowsSourceRoot, 'autounattend.xml')
$archiveDir = [System.IO.Path]::Combine($_root, 'archive')
if ($ArchiveUnattendFile) {
if (-not (Test-Path -Path "$archiveDir" -PathType Container)) {
New-Item $archiveDir -ItemType Directory
}
if (Test-Path -Path "$targetUnattendFile") {
$archiveName = [System.IO.Path]::Combine($archiveDir, ".\_autounattend.xml.$((Get-Date).ToString("yyyyMMddHHmmss"))")
Copy-Item $targetUnattendFile $archiveName
}
}
Copy-Item $UnattendFile $targetUnattendFile
& $_oscdimg -m -o -u2 -udfver102 -bootdata:1#pEF,e,b$efiBin "$WindowsSourceRoot" "$IsoDest"
}
function Create-TestVM {
param (
[Parameter(Mandatory)]
[string]$VMName,
[Parameter(Mandatory)]
[string]$IsoSource
)
$vmDiskDir = [System.IO.Path]::Combine($_root, 'vm')
$vhdx = [System.IO.Path]::Combine($vmDiskDir, 'win11.vhdx')
if (-not (Test-Path $vmDiskDir -PathType Container)) {
New-Item $vmDiskDir -ItemType Directory
}
$vm = New-VM -Name $VMName -MemoryStartupBytes 4GB -Generation 2 -NewVHDPath $vhdx -NewVHDSizeBytes 100GB -SwitchName $swName
$dvd = Add-VMDvdDrive -VM $vm -Path $IsoSource -Passthru
Set-VMFirmware -VM $vm -FirstBootDevice $dvd
Set-VMProcessor -VM $vm -Count 2
# disable checkpoints
Set-VM $vm -AutomaticCheckpointsEnabled:$false
# tpm
$owner = Get-HgsGuardian UntrustedGuardian
$kp = New-HgsKeyProtector -Owner $owner -AllowUntrustedRoot
Set-VMKeyProtector -VM $vm -KeyProtector $kp.RawData
Enable-VMTPM -VM $vm
# start
Start-VM $vm
}
$isoFullName = [System.IO.Path]::Combine($_root, $iso)
Remove-TestVM -VMName $vmName
Update-TestISO -UnattendFile $_root\autounattend.xml -WindowsSourceRoot $_root\iso -IsoDest $isoFullName
Create-TestVM -VMName $vmName -IsoSource $isoFullName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment