Published: Sep 30, 2024
In this article, I’ll show you how to list Active Directory users with PowerShell. While you can also list Active Directory (AD) users in Active Directory Users and Computers, PowerShell provides a much faster way.
Check out how to list Active Directory Users with ADUC on Petri if you would prefer to perform this action using a GUI tool.
Let’s look at the main method to list Active Directory users – PowerShell, or, more accurately, the Active Directory Module for Windows PowerShell. Check out this article on Petri if you need to install the Active Directory Module for PowerShell.
First off, let’s try listing Active Directory users with PowerShell, and format them in table format with the Get-AdUser command
Get-ADUser -filter * | ft
We used the ‘-filter‘ command and chose ‘*’ for all. Then, we ‘piped’ | the output to Format-Table (ft) format.
Now, let’s filter for all the wonderful people in the Reinders clan. We only need the Name and SamAccountName for each, so we’ll add attributes at the end, meaning we ONLY want to see those items.
Get-ADUser -Filter 'Name -like "*Reinders*"' | ft Name,SamAccountName
Piece of cake. Let’s get a list of all disabled accounts. We’ll use the following command:
Get-ADUser -Filter {(Enabled -eq $False)} | ft Name,SamAccountName
In case you’re unaware, there are dozens of attributes in each user account. Let’s get a glimmer of those for Billy Reinders with another variation.
Get-ADUser -Identity breinders -Properties *
That is about half of them. One nice thing you can do when desiring specific output is to use wildcard characters for what attributes you want.
How about any attribute to do with ‘name’?
Get-ADUser -Identity breinders -Properties *Name*
Listing Active Directory users with PowerShell and the Get-ADUser cmdlet is easy. As you have seen, you can apply various filters to get the results you want or simply get a complete list of users.