How do I get the TypeName of an object piped to Get-member?

Hello,
When I pipe an object to Get-Member, I get a very useful listing of methods, properties, etc. At the very top, i.e., the first line of the output is something that begins with info on the object’s type. Examples:

TypeName: System.Data.Dataset
TypeName: System.String

I can see a GetType() method in the Get-member output list, but how do I invoke it to get just that first line (assuming this is the correct method needed)?

Would be grateful for any tips or suggestions.

 

I guess this might work. My testing shows the same short name as the type that get-member does except with arrays it can show object. Not sure why.

$oht = [ordered]@{Hash='value';Table='value'}

$oht.GetType().name
OrderedDictionary

 

$arr = New-Object System.Collections.ArrayList

$arr.Add('value')

$arr.GetType().name
ArrayList

 

$arr = @(@{Hash='value';Table='value'})

$arr.GetType().name
Object[]

 

I believe there can also be a difference between

$variable | Get-Member

and

Get-Member -InputObject $variable

 

Another thing to note is an array may contain multiple types

$arr = @(1,'string')

$arr.ForEach({$_.gettype().name})
Int32
String

 

I hope this helps.

Many thanks Mr Maurer, for your answer/solution with thought-provoking examples. While I was struggling with the GetType() within Get-member, I came up with the ff:

b$ = "a string"
b$ | Get-member | Out-string -Stream | Select-string "Typename:" -Noemphasis

Obviously, my mindset was set on strings rather than objects.

Thanks again for your response.