PowerShell: Count enabled user accounts

A few weeks ago, I showed you how to get a list of all enabled user accounts in PowerShell. Perhaps unsurprisingly, after having presented this to my customer, it transpired that what they really wanted, was to know how many enabled user accounts existed in Active Directory.

Once more, my Google-fu put me on the right track, as I found this article, which gave me the solution right out of the gate. By using the query (Get-AdUser -filter * |Where {$_.enabled -eq "True"}).count, you get exactly what my customer requested.

Naturally, you can use a variant of the query to count the number of disabled user accounts in Active Directory, too: (Get-ADUser -filter * |Where {$_.enabled -ne "False"}).count.


Posted

in

by

Tags:

Comments

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

This site uses Akismet to reduce spam. Learn how your comment data is processed.