Author Posts

June 13, 2017 at 8:31 pm

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?


June 13, 2017 at 8:40 pm

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.

June 13, 2017 at 10:11 pm

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.

June 13, 2017 at 10:13 pm

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.

June 13, 2017 at 10:20 pm

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)

June 13, 2017 at 11:05 pm

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

Where, then Measure, then Select.

June 14, 2017 at 8:50 pm

ah, Check... Thank ya kindly.