Author Posts

October 16, 2013 at 5:32 am

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.

October 16, 2013 at 6:44 am

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.

October 16, 2013 at 8:59 am

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 :).

October 16, 2013 at 10:22 am

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?