How can I list all the Titles for Namespace?

Welcome Forums General PowerShell Q&A How can I list all the Titles for Namespace?

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

 
Participant
5 years, 4 months ago.

  • Author
    Posts
  • #8587

    Participant
    Points: 0
    Rank: Member

    Situation
    I created a Shell Application type of ComObject
    Get-Member reveals it has a ‘Namespace’ method.
    Example

    $Shell = New-Object -ComObject Shell.Application
    $Shell.NameSpace

    I can make a few luck guesses for instance (0x5)

    $Shell.NameSpace(0x5)

    Title ‘My Documents’.

    Question: How can I list all the Titles for Namespace?

  • #8591

    Participant
    Points: 0
    Rank: Member

    Looks like it takes an integer.  You could do something like this and work with the objects as desired (e.g. select -expandproperty Title, work with the self property, etc).  For example:

    
    $shell = New-Object -ComObject Shell.application
    
    1..60 | %{ $shell.namespace($_) | ?{$_.title} | select -expandproperty Title }

    Another example:

    foreach($i in $(1..60)){
    
    $shell.namespace($i) | ?{$_.title} | select @{l="index";e={$i}}, Title, @{l="Path";e={$_.Self.Path} }
    
    }
  • #8592

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

    And, to directly answer your question, there is no programmatic way of listing the integers that it will accept. You'll have to guess, or do as suggested and see what exists on your system. That's an old COM object and doesn't provide a lot of discoverability.

  • #8596

    Participant
    Points: 0
    Rank: Member

    Dear Cookie Monster

    Brilliant, stunning, just what I wanted. Naturally, it worked just as you indicated, thank you.

  • #8604

    Participant
    Points: 0
    Rank: Member

    I did document most of the common ones in the appendix of PowerShell in Practice

The topic ‘How can I list all the Titles for Namespace?’ is closed to new replies.