diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index b9220218..ece7d749 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -5,6 +5,8 @@ $null = $env:SETUP_SCRIPT_NAME; $drives = & wmic volume get "DriveLetter,Label"; $drive = $($($drives | Select-String -Pattern "winiso") -split "\s+")[0]; [xml]$unattendedConfig = $(Get-Content "$drive\Autounattend.template.xml"); +$namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $unattendedConfig.NameTable; +$namespace.AddNamespace("ua", $unattendedConfig.DocumentElement.NamespaceURI); function Get-PassSettings { [OutputType([xml])] @@ -12,15 +14,15 @@ function Get-PassSettings { [string] $passName ) - return $unattendedConfig.SelectSingleNode("/unattend/settings[@pass='$passName']"); + return $unattendedConfig.SelectSingleNode("/ua:unattend/ua:settings[@pass='$passName']", $namespace); } # Adjust unattended settings $specializeSettings = Get-PassSettings "specialize"; -$specializeSettings.SelectSingleNode("./component[@name='Microsoft-Windows-Shell-Setup']/ComputerName").InnerText = "$env:WIN_COMPUTER_NAME"; +$specializeSettings.SelectSingleNode("./ua:component[@name='Microsoft-Windows-Shell-Setup']/us:ComputerName", $namespace).InnerText = "$env:WIN_COMPUTER_NAME"; $oobeSystemSettings = Get-PassSettings "oobeSystem"; -$oobeSystemSettings.SelectSingleNode("./component/FirstLogonCommands/SynchronousCommand[last()]/CommandLine").InnerText += "`npwsh 'PortValhalla/$env:SETUP_SCRIPT_NAME';"; +$oobeSystemSettings.SelectSingleNode("./ua:component/us:FirstLogonCommands/us:SynchronousCommand[last()]/us:CommandLine", $namespace).InnerText += "`npwsh 'PortValhalla/$env:SETUP_SCRIPT_NAME';"; Write-Warning "Attention: This program will completely wipe your current disk #1 and install Windows on it. Are you sure you want to do this?" Read-Host -Prompt "Hit enter to continue or CTRL+C to abort"