I have the following XML:
<?xml version="1.0" encoding="utf-8"?>
<Topology>
<MyProjectserver1 desc="name of the server"></MyProjectserver1>
</Topology>
I have tried the following, but it did not get update
$path = 'C:\newfolder\data.xml'
$MyProjectserver1 ='XYZAB'
$xml =[xml](Get-Content -Path $path)
$node =$xml.Topology.MyProjectserver1 |
Where {$_.desc -eq 'name of the server'}
$node =$MyProjectserver1
$xml.Save($path)
Once the above PowerShell script is executed, it did not update the XML content.
Ideally, the PowerShell script should update the server name in XML content as below:
<?xml version="1.0" encoding="utf-8"?>
<Topology>
<MyProjectserver1 desc="name of the server">XYZAB</MyProjectserver1>
</Topology>