XML Config file

Found a nice article on how to load your config from an XML file


Load config from XML file

<?xml version="1.0" encoding="utf-8" ?>


  <QueueServer name="blah"/>



$cfg =[xml](Get-Content "C:\scripts\PowerShell\QueueServers.xml")

$servername = $cfg.configuration.QueueServer.name

Load and modify XML file

Another example from stackoverflow



  <one>I like applesauce</one>

  <two>You sure bet I do!</two>


# load XML file into local variable and cast as XML type. $doc = [xml](Get-Content ./test.xml)  $doc.root.one                                   #echoes "I like applesauce" $doc.root.one = "Who doesn't like applesauce?"  #replace inner text of <one> node  # create new node... $newNode = $doc.CreateElement("three") $newNode.set_InnerText("And don't you forget it!")  # ...and position it in the hierarchy $doc.root.AppendChild($newNode)  # write results to disk $doc.save("./testNew.xml")


  <one>Who likes applesauce?</one>

  <two>You sure bet I do!</two>

  <three>And don't you forget it!</three>