__ComObject formatting

Is it possible to use a ps1xml format specification to format specific COM object types? I’ve tried searching but the closest I’ve found was extending the base System.__ComObject type to add functionality. I want to format a specific COM type.

Huh. I’ve never tried. In theory, if it shows a TypeName when you pipe the object to Get-Member, then you should be able to build a view on it. But without trying it, I can’t say for sure.

Ah… I think I see how to do it. System.__ComObject isn’t enough. Get-Member shows TypeName as System.__ComObject#{Guid}, and that’s what I need to use. A quick test shows this to be the case. Stupid question, so thanks for helping me think about it more intelligently and arriving at the answer :).

In many cases the COM object is embedded in the returned object so you will need to unravel that to get to the point of being able to format the COM object. I would certainly think about the return on doing this - is it worth the effort?