It is fine to list users manually when you have a few, but can be just unthinkable when you have a thousand! Fortunately, PowerShell can make it easy for you. The following command will list all the users (even those who are disabled) with a lot of useful information.
The command to use is :
Get-ADUser -Filter * -SearchBase "ou=ORGANISATIONAL UNIT NAME,dc=domain,dc=tld"
Example : let’s say we want to query the organisational unit (OU) named “TECH DEPARTMENT” and the domain “itechlounge.net”, the command will look like :
Get-ADUser -Filter * -SearchBase "ou=TECH DEPARTMENT,dc=itechlounge,dc=net"
NOTE : You may add an additional “dc=” statements if you are querying a subdomain (example : rnd.itechlounge.net would result in “dc=rnd,dc=itehclounge,dc=net).
The command will output a list like :
DistinguishedName : CN=Name\, Last Name,OU=TECH DEPARTMENT,DC=itechlounge,DC=net
Enabled : True
GivenName : LastName
Name : FirstName, LastName
ObjectClass : user
ObjectGUID : 9e4b9e2d-bce5-41f1-803d-dd152d415e0c
SamAccountName : username
SID : S-1-5-21-424064557-304900108-2426736585-1107
Surname : LastName
UserPrincipalName : username@itechlounge.net