Count users attributes in AD

Welcome Forums General PowerShell Q&A Count users attributes in AD

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
3 years ago.

  • Author
    Posts
  • #46831

    Participant
    Topics: 2
    Replies: 3
    Points: 1
    Rank: Member

    Hello, guys
    I need to count how many user attributes we have in our Active directory.
    The command
    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
    Please help

  • #46835

    Participant
    Topics: 18
    Replies: 573
    Points: 32
    Rank: Member

    fyi, properties * doesn't contain all attributes.

  • #46837

    Participant
    Topics: 18
    Replies: 573
    Points: 32
    Rank: Member

    (get-aduser me -Properties * |gm -MemberType property).count

    • #46848

      Participant
      Topics: 2
      Replies: 3
      Points: 1
      Rank: Member

      Thank you guys.
      Your answers were really fast!
      Both variants are working.

  • #46842

    Participant
    Topics: 0
    Replies: 44
    Points: 45
    Rank: Member

    Instead of .Count or .Length, use .PropertyCount

    i.e: (Get-ADUser -Identity Administrator -Properties *).PropertyCount

  • #46865

    Participant
    Topics: 18
    Replies: 573
    Points: 32
    Rank: Member

    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.