Make VirtIO and automatic logon opt-in in the Windows 11 configure script

Add -InstallVirtIO and -EnableAutomaticLogon switches to
Configure-Windows.ps1 so it can run standalone on a physical machine.
Autounattend.xml passes both switches during the virtual machine install.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GuofangandClaude Sonnet 5.5 committed 2026-10-15 10:00:37 +08:00
1 parent 1691062554
commit 96c689b03e
2 files changed
+12 -3

No files matched your search

+1 -1
View File
@@ -162,7 +162,7 @@
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<Description>Configure Windows from the answer-media script</Description>
<CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$script = Get-ChildItem -Path (Get-PSDrive -PSProvider FileSystem).Root -Filter 'Configure-Windows.ps1' -File -ErrorAction SilentlyContinue | Select-Object -First 1; if (-not $script) { throw 'Configure-Windows.ps1 was not found on the attached media.' }; &amp; $script.FullName"</CommandLine>
<CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$script = Get-ChildItem -Path (Get-PSDrive -PSProvider FileSystem).Root -Filter 'Configure-Windows.ps1' -File -ErrorAction SilentlyContinue | Select-Object -First 1; if (-not $script) { throw 'Configure-Windows.ps1 was not found on the attached media.' }; &amp; $script.FullName -InstallVirtIO -EnableAutomaticLogon"</CommandLine>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
+11 -2
View File
@@ -1,3 +1,8 @@
param(
[switch]$InstallVirtIO,
[switch]$EnableAutomaticLogon
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
@@ -91,7 +96,11 @@ function Enable-AutomaticLogon {
Remove-ItemProperty -Path $winlogonPath -Name 'AutoLogonCount' -ErrorAction SilentlyContinue
}
Install-VirtIOGuestTools
if ($InstallVirtIO) {
Install-VirtIOGuestTools
}
Install-OpenSSHServer
Install-AdministratorAuthorizedKey
Enable-AutomaticLogon
if ($EnableAutomaticLogon) {
Enable-AutomaticLogon
}