In many cases, we found ourselves in a situation where we need to Read and update XML files.
It’s quite straight forward in Power Shell.
Sample XML File:
Powershell script to read and update XML file
<App> | |
<Secret></Secret> | |
</App> |
Powershell script to read and write XML file
$xmlFileName "Path to XML File"; | |
[xml]$xmlDoc = Get-Content $xmlFileName | |
$xmlDoc.APP.Secret = "Some Value" | |
$xmlDoc.Save($xmlFileName) |