diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index 17480900e..a268abd10 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -4,7 +4,14 @@ $null = $env:SETUP_SCRIPT_NAME; # Find `winiso` installation medium $drives = & wmic volume get "DriveLetter,Label"; $drive = $($($drives | Select-String -Pattern "winiso") -split "\s+")[0]; -[xml]$unattendedConfig = $(Get-Content "$drive\Autounattend.template.xml"); +[xml]$unattendedConfig = [xml]::new(); +$unattendedConfig.PreserveWhitespace = $true; + +$readerSettings = [System.Xml.XmlReaderSettings]::new(); +$readerSettings.IgnoreComments = $true; +$reader = [System.Xml.XmlReader]::Create("$drive\Autounattend.template.xml", $readerSettings); + +$unattendedConfig.Load($reader); $namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $unattendedConfig.NameTable; $namespace.AddNamespace("ua", $unattendedConfig.DocumentElement.NamespaceURI);