Discover Hidden Object Members

by Jun 16, 2010

Get-Member is a great cmdlet to discover object members, but it will not show everything:

"Hello" | Get-Member

You should add -force to really see a complete list of object members:

"Hello" | Get-Member -force

One of the more interesting hidden members is called PSTypeNames and lists the types this object was derived from:

"Hello".PSTypeNames

These types become important when PowerShell formats the object. The first type in that PSTypeNames-list that can be found in PowerShell’s internal type database is used to format the information. To prove that point, you should check out what happens if you manipulate that information:

$a = "Hello"
$a.pstypenames.Clear()
$a
$a -eq 'Hello'
True

Without PSTypeNames, PowerShell no longer knows how to format the string and will display empty space instead.