February 11th, 2014

PowerTip: Use PowerShell to Edit XML File

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to load an XML file for easy editing.

Hey, Scripting Guy! Question Hey Scripting Guy! Is there an easy way to load and edit an XML file in Windows PowerShell?

Hey, Scripting Guy! Answer It’s so easy that you might miss it if you blink. Create an XML object. With that, you can load, save, and edit properties directly:

$XMLfile=NEW-OBJECT XML

$XMLfile=load(“MyXMLFile.XML”)

$XMLFile.property.otherproperty=”Gibberish”

$XMLFile.save(“MyXMLFile.XML”)

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.