I'm trying to rename an XML node using PowerShell. For example:
<configuration>
<desktops>
<name>PC001</name>
<domain>CORP</domain>
</desktops>
<laptops>
<name>PC002</name>
<domain>CORP</domain>
</laptops>
</configuration>
I want to rename the first <name> tags to <PC1name> (and </PC1name> respectively). Here's what I have, so far:
$InputFile = "NetworkConfigs.xml"
$xml = [xml](get-content $InputFile)
$root = $xml.get_DocumentElement();
#replace the node
$root.desktops.name.?
$xml.Save($InputFile)
I don't know how to replace the <name> tag with something else. Tips?