Get-member returns different TypeName of the same variable

Hello,

I have a question about the Object Type returned by the Get-Member command.
I have the following code:

$svc = get-service     # stores a collection of service objects(System.ServiceProcess.ServiceController) in the svc variable
$svc | Get-Member      #returns TypeName: System.ServiceProcess.ServiceController
Get-Member -InputObject $svc  # returns TypeName: System.Object[]

Why does Get-member returns two different type of object for the content of the same variable?

Because of the different amount of objects you feed it. Try only one instead of all of them …

Get-Member -InputObject $svc[0]

:wink:

1 Like

The first you are piping the objects into get member. The second is doing a get-member on the container of the objects

1 Like