How do I count the # of properties returned from a Get-?

I ran this:

Get-ADObject -Filter {name -like ‘Unique_Bob’} -Properties * -Server | measure

…but actually wanted to count the total of all properties returned (not just the number of users named “bob”).

How could I quickly accomplish this?


Pipe to Get-Member, and then pipe that output to Where-Object to filter for only those members which are properties, and pipe that to Measure-Object.

Thanks Don

Get-ADObject -Filter {name -like 'Unique_Bob'} -Properties * -Server | gm | Where-Object MemberType -EQ Property | measure

How do I do that trick where I just get the “count”?

Tried this:

Get-ADObject -Filter {name -like ‘Unique_Bob’} -Properties * -Server | gm | Where-Object MemberType -EQ Property | (measure).count
and went down in flames.

Yeah, that’s because you’re executing Measure as a single command with no input. That’s what parentheses do. You’re trying to copy something you’ve seen in other contexts ;).

Just add “| Select-Object Count” to the end if you only want to see the Count property.

hmm I see this:

... gm | Where-Object MemberType -EQ Property | Select-Object count


(lots of empty space but no "measured’ count of the Property’s)

Well, you deleted Measure-Object, dude. That’s what generates an object with the Count property.

Where, then Measure, then Select.

ah, Check… Thank ya kindly.