Set the name of the setup user properly

This commit is contained in:
Manuel Thalmann 2024-08-06 10:22:50 +02:00
parent 6997a800b9
commit 4f17c95487

View file

@ -205,8 +205,15 @@ function Start-Setup {
$computerName.InnerText = "$env:WIN_COMPUTER_NAME"; $computerName.InnerText = "$env:WIN_COMPUTER_NAME";
# Execute corresponding installer script after startup # Execute corresponding installer script after startup
$oobeSystemSettings = Get-PassSettings "oobeSystem"; $oobeSettings = (Get-Component (Get-PassSettings "oobeSystem") "Microsoft-Windows-Shell-Setup");
$installationCommand = $oobeSystemSettings.SelectSingleNode("./ua:component/ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace);
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 = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true));
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = ` $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `