View number of User Accounts in AD via AD PowerShell
Below are 3 simple commands that display how many users you have in AD, how many users that are enabled and also how many that are disabled.Number of User Accounts
(get-aduser -filter ).countNumber of Enabled User Accounts
(get-aduser -filter *|where {$_.enabled -eq “True”}).countNumber of Disabled User Accounts
(get-aduser -filter *|where {$_.enabled -ne “False”}).count
출처: <http://support.risualblogs.com/blog/2012/07/24/view-number-of-user-accounts-in-ad-via-ad-powershell/>
(Get-ADUser -Filter * -SearchBase “ou=Accounting,ou=administration,ou=people,dc=ncmecad,dc=net”).count
출처: <http://www.experts-exchange.com/Software/Server_Software/Active_Directory/Q_28415501.html>
0. 현재 상태
Accounting OU에는 3명.
ITAdmins OU에는 6명.
1. PowerShell
SearchBase 옵션으로 특정 OU에 대한 사용자를 쿼리하고, (명령).count 옵션으로 카운트.
(Get-ADUser -Filter * SearchBase “OU=Accounting,DC=Adatum,DC=com”).count
(Get-ADUser -Filter * SearchBase “OU=ITAdmins,DC=Adatum,DC=com”).count
2. dsquery
dsquery 구문을 사용하는 방법. 앞쪽에 1: 2: 3: 4: 5: 6: 이런식으로 카운트됨.
dsquery user OU=ITAdmins,DC=Adatum,DC=com -limit 5000 | findstr /r /n “^”
dsquery user OU=Accounting,DC=Adatum,DC=com -limit 5000 | findstr /r /n “^”