locked
What is the powershell command to get the user count in Active Directory RRS feed

  • Question

  • What is the powershell command to get the user count in Active Directory
    Friday, April 10, 2015 10:21 AM

Answers

  • (get-aduser -filter *).count 

    This will give you the number of user objects in AD

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    • Marked as answer by Mahdi Tehrani Saturday, April 18, 2015 2:03 PM
    Friday, April 10, 2015 10:34 AM
  • Add to this..

    For only Enabled User Accounts
    (get-aduser -filter *|where {$_.enabled -eq "True"}).count

    For only Disabled User Accounts
    (get-aduser -filter *|where {$_.enabled -ne "False"}).count


    Devaraj G | Technical solution architect

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    • Marked as answer by Mahdi Tehrani Saturday, April 18, 2015 2:03 PM
    Friday, April 10, 2015 11:05 AM

All replies

  • Get-ADuser

    REF: http://blogs.technet.com/b/heyscriptingguy/archive/2012/10/30/powertip-single-line-powershell-command-to-list-all-users-in-an-ou.aspx


    This post is provided AS IS with no warranties or guarantees, and confers no rights.
    ~~~
    Questo post non fornisce garanzie e non conferisce diritti

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    Friday, April 10, 2015 10:22 AM
  • (get-aduser -filter *).count 

    This will give you the number of user objects in AD

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    • Marked as answer by Mahdi Tehrani Saturday, April 18, 2015 2:03 PM
    Friday, April 10, 2015 10:34 AM
  • Hi,

    You can use below script and modify the attribute you want based on your requirement.

    Get-Aduser -Filter * -Properties *|select name,@{n="memberof";e={[string]$_.memberof}},SamAccountName,PasswordExpired,PasswordLastSet,LastLogonDate,Enabled,DistinguishedName,DisplayName,GivenName,SurName|export-csv C:\output.csv

    Note: To run this script you need to Powershell 2.0

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    • Unproposed as answer by Mahdi Tehrani Saturday, April 18, 2015 2:04 PM
    Friday, April 10, 2015 11:04 AM
  • Add to this..

    For only Enabled User Accounts
    (get-aduser -filter *|where {$_.enabled -eq "True"}).count

    For only Disabled User Accounts
    (get-aduser -filter *|where {$_.enabled -ne "False"}).count


    Devaraj G | Technical solution architect

    • Proposed as answer by Vivian_Wang Tuesday, April 14, 2015 6:51 AM
    • Marked as answer by Mahdi Tehrani Saturday, April 18, 2015 2:03 PM
    Friday, April 10, 2015 11:05 AM
  • Hi,

    If your query is resolved kindly click on proposed answer.

    Friday, April 10, 2015 11:46 AM