Powershell Help to edit XML file
New at this, and would like some help to edit a .xml file with Powershell. The XML file is located locally on a workstation. I'm trying to change the AuthenticationType to "Kerberos" Everything I've tried runs with no errors but does not change the value. Any help would be greatly appreciated.
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
rileyz
4 years ago
Bang.
Its not the best code I have written, but also not the worst - but most importantly it does what says on the tin ✌
$XML = "C:\Media\Test.txt"
$XMLContent = Get-Content "C:\Media\Test.txt"
Rename-Item -Path $XML -NewName ($XML + '.Backup')
$XMLContent = $XMLContent -replace 'authenticationType="Basic"','authenticationType="Kerberos"'
$XMLContent | Out-File $XML