How to List Active Directory Users with PowerShell

Published: Sep 30, 2024

1725501059 powershell hero

SHARE ARTICLE

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.

PowerShell – list Active Directory users

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.

In Administrative Tools, we have the Active Directory Module for Windows PowerShell
In Administrative Tools, we have the Active Directory Module for Windows PowerShell (Image Credit: Petri.com/Michael Reinders)

Finding all Active Directory users with the PowerShell Get-AdUser cmdlet

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
List Active Directory users with PowerShell
List Active Directory users with PowerShell (Image Credit: Petri.com/Michael Reinders)

We used the ‘-filter‘ command and chose ‘*’ for all. Then, we ‘piped’ | the output to Format-Table (ft) format.

Filtering results with PowerShell

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
The Reinders Family...in Active Directory
The Reinders Family…in Active Directory (Image Credit: Petri.com/Michael Reinders)

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
List all disabled Active Directory users with PowerShell
List all disabled Active Directory users with PowerShell (Image Credit: Petri.com/Michael Reinders)

Checking attributes for user accounts in Active Directory

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 *
All (mostly) the attributes for Billy Reinders
All (mostly) the attributes for Billy Reinders (Image Credit: Petri.com/Michael Reinders)

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*
This outputs the core attributes and the ones with 'Name' in them
This outputs the core attributes and the ones with ‘Name’ in them (Image Credit: Petri.com/Michael Reinders)

Conclusion

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.

SHARE ARTICLE