From 4f17c954879e621bf6b0ec588536e14990ce08d9 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 6 Aug 2024 10:22:50 +0200 Subject: [PATCH] Set the name of the setup user properly --- scripts/Windows/OS/Setup.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index a6c02689..344d742d 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -205,8 +205,15 @@ function Start-Setup { $computerName.InnerText = "$env:WIN_COMPUTER_NAME"; # Execute corresponding installer script after startup - $oobeSystemSettings = Get-PassSettings "oobeSystem"; - $installationCommand = $oobeSystemSettings.SelectSingleNode("./ua:component/ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace); + $oobeSettings = (Get-Component (Get-PassSettings "oobeSystem") "Microsoft-Windows-Shell-Setup"); + + foreach ($xpath in @("./ua:AutoLogon/ua:Username", + "./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/Name", + "./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/DisplayName")) { + $oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser; + } + + $installationCommand = $oobeSettings.SelectSingleNode("./ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace); $newCommand = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true)); $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `