Author Posts

June 27, 2013 at 6:46 am

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.

June 27, 2013 at 6:52 am

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.

June 27, 2013 at 7:13 am

[quote=7929]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.[/quote]

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.

June 27, 2013 at 7:54 am

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.

June 27, 2013 at 9:32 am

[quote=7931]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.[/quote]

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