Edit unattend file XML Powershell Script - nonoloki2/Devops GitHub Wiki

#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment

#--- Convert all of the variables currently in the environment to PowerShell variables $tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }

$attendfile = "C:\Windows\Panther\Unattend\unattend.xml" #(Get-Content $attendfile).Replace('System_Locale',$UserLocale) | Set-Content $attendfile #(Get-Content $attendfile).Replace('User_Locale',$UserLocale) | Set-Content $attendfile (Get-Content $attendfile).Replace('System_Locale',$UserLocale) | Set-Content $attendfile (Get-Content $attendfile).Replace('User_Locale',$UserLocale) | Set-Content $attendfile (Get-Content $attendfile).Replace('UI_Language',$UILanguage) | Set-Content $attendfile (Get-Content $attendfile).Replace('Input_Locale',$KeyboardLocale ) | Set-Content $attendfile (Get-Content $attendfile).Replace('Time_Zone',$OSDTimeZone ) | Set-Content $attendfile