What to do with XML

I have a custom ComObject that I connect to. Â It has a property that I call. Â It outputs in XML format. Â From that point I’m curious what my options are for viewing this XML? Â I’m familiar with reading XML files using get-content. Â In this case, the XML is not in a file that get-content can work with. Â So I guess that option is out? Â I do not want to write the output of the ComObject’s property to a file, but want to do something in Powershell with it to make it more readable. Â Then maybe move it into a file.

What type of object are you getting back from your property? Is it a System.Xml.XmlDocument? If so, you can reference the OuterXml property on that object to view the Xml document.

How can I tell what type of object it is coming back? Â After I create the -ComObject, I’m calling it with $variable.property. Â It outputs XML.

It’s likely that the XML is being returned as a text string instead of a PowerShell XML object. Try converting it by doing something like this: $xmlData = [xml]$variable.property. You should then be able to process $xmlData in exactly the same way as your imported xml files.

Wow! Â That is slick! Â Worked great. Â Thank you very much.