Q. Can PowerShell read and parse XML files?

Yes, although the means isn't very obvious. See this article to find out how!

Don Jones

September 14, 2010

1 Min Read
open book with paper planes coming from it

Q. Can PowerShell read and parse XML files?

A. Yes, although the means isn't very obvious. If you have an XML file named Mine.xml, do this:

[xml]$xml = Get-Content Mine.xml

That'll read the file, parse the XML, and construct within the $xml variable an object tree based on the XML structure. Run

$xml | Get-Member

to see the root of the object hierarchy. For more information, see the introductory tutorial "PowerShell and XML".

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like