How can I list all the Titles for Namespace?

This topic contains 4 replies, has 4 voices, and was last updated by  Richard Siddaway 5 years ago.

  • Author
  • #8587

    Guy Thomas

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

    $Shell = New-Object -ComObject Shell.Application

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


    Title ‘My Documents’.

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

  • #8591

    Warren Frame

    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

    Don Jones

    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

    Guy Thomas

    Dear Cookie Monster

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

  • #8604

    Richard Siddaway

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

You must be logged in to reply to this topic.