This topic contains 5 replies, has 3 voices, and was last updated by
July 13, 2016 at 6:42 pm #46831ParticipantTopics: 2Replies: 3Points: 1Rank: Member
I need to count how many user attributes we have in our Active directory.
Get-ADUser -identity Administrator -properties *
gives me all information about attributes but I can't calculate them.
@(Get-ADUser -identity Administrator -properties *).Count # returns 1
@(Get-ADUser -identity Administrator -properties *).Length # returns 1
$output=Get-ADUser -identity Administrator -properties *
@($output).Count # returns 1
July 13, 2016 at 6:56 pm #46835
fyi, properties * doesn't contain all attributes.
July 13, 2016 at 6:58 pm #46837
(get-aduser me -Properties * |gm -MemberType property).count
July 13, 2016 at 7:13 pm #46848ParticipantTopics: 2Replies: 3Points: 1Rank: Member
Thank you guys.
Your answers were really fast!
Both variants are working.
July 13, 2016 at 7:02 pm #46842ParticipantTopics: 0Replies: 44Points: 45Rank: Member
Instead of .Count or .Length, use .PropertyCount
i.e: (Get-ADUser -Identity Administrator -Properties *).PropertyCount
July 13, 2016 at 7:42 pm #46865
Good one Matt. Hard to break old habits:D
Get-ADObject -filter * -SearchBase (Get-ADRootDSE).schemaNamingContext | where objectclass -like "attributeschema" |select name
now figure out how you can find those only related to the user class:D
The topic ‘Count users attributes in AD’ is closed to new replies.