I ran this:
Get-ADObject -Filter {name -like ‘Unique_Bob’} -Properties * -Server domain.com | 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?
thanks
donj
June 13, 2017, 3:10pm
2
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 domain.com | 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 domain.com | gm | Where-Object MemberType -EQ Property | (measure).count and went down in flames.
donj
June 13, 2017, 4:43pm
4
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
count
-----
(lots of empty space but no "measured’ count of the Property’s)
donj
June 13, 2017, 5:35pm
6
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.