How can I list all the Titles for Namespace?

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?

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} }

}

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.

Dear Cookie Monster

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

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