Using PowerShell to add new child node in element

By | March 8, 2016

Code template:

$path = '<path to xml file>'

 $xml = Get-Content($path)

$newNode = $xml.CreateElement('<name of new element>')
$newNode.SetAttribute('<Attribute key>','<Attribute value>')

‘ParentElement’ is the name of the element which you want to add the new child to.
Always remember to save the file or it will not be updated.

Leave a Reply