PowerTip: Search for Inactive User Accounts in Windows Server 2012 Active Directory

Summary: Learn how to use Windows PowerShell to search for inactive user accounts in Active Directory for Windows Server 2012.

Hey, Scripting Guy! Question How can I query inactive user accounts in my Windows Server 2012 Active Directory environment?

Hey, Scripting Guy! Answer Charlotte Windows PowerShell user group member Brian Wilhite says: You can use the ActiveDirectory module that contains the Search-ADAccount cmdlet used to query inactive user and computer accounts. For user accounts only, you’ll use the UsersOnly parameter.

Search-ADAccount -AccountInactive -UsersOnly

You can also use the TimeSpan parameter to specify account inactivity. the example below specifies 30 days of inactivity.

Search-ADAccount -AccountInactive -UsersOnly -TimeSpan 30.00:00:00

Comments (6)

  1. Anonymous says:


    just add this at the end of the line:

    | where {$_.enabled}

  2. Anonymous says:

    Also, you can use this same method in a 2008 R2 domain as well.

  3. Anonymous says:

    Thanks for the valuable information about how to find out inactive in AD environment, I found this utility from
    http://www.lepide.com/active-directory-cleaner/ which helps to find out inactive user accounts and manage active directory accounts

  4. Pitchdown says:


    how can i pipeline with "enabled=True" to find only enabled accounts?


  5. Steve Poirier says:

    This should provide a bit cleaner output:

    Search-ADAccount -AccountInactive -UsersOnly -TimeSpan 30.00:00:00 | where {$_.enabled} | Select-Object Name | Sort-Object Name

  6. Rahman says:

    Inactive account tracker tool may help you to find inactive users.

    find here http://www.adsysnet.com/downloads.aspx

Skip to main content