__ComObject formatting

Welcome Forums General PowerShell Q&A __ComObject formatting

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
5 years, 3 months ago.

  • Author
    Posts
  • #10780

    Participant
    Points: 0
    Rank: Member

    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.

  • #10782

    Keymaster
    Points: 1,785
    Helping HandTeam Member
    Rank: Community Hero

    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.

  • #10783

    Participant
    Points: 0
    Rank: Member

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

  • #10789

    Participant
    Points: 0
    Rank: Member

    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?

The topic ‘__ComObject formatting’ is closed to new replies.