We're Hiring!
Take the next step in your career and work on diverse technology projects with cross-functional teams.
LEARN MORE
Mountain West Farm Bureau Insurance
office workers empowered by business technology solutions
BLOG
2
14
2012

Query for User Accounts in Active Directory with PowerShell

Last updated:
7.23.2021

Occasionally there is a need to quickly query Active Directory for all user accounts or user accounts with only certain values in particular properties. This can be done by installing and loading the Microsoft Active Directory Administration module for PowerShell. This is an add-on module, named ActiveDirectory, that provides cmdlets that let you manage your Active Directory domains.

After you install the ActiveDirectory module, there is now a new PowerShell option in Administrative Tools, called Active Directory Module for Windows PowerShell:

screen1.png

This brings up the bland, DOS-like command prompt with the ActiveDirectory module automatically loaded. But what if you like to work in the Windows PowerShell Integrated Scripting Environment (ISE)? Start up ISE and then run the following command:

Import-module ActiveDirectory

That will load the ActiveDirectory module into your ISE session, so that you can use the desired cmdlets.

Querying for User Accounts

To query for user accounts, use the Get-ADUser cmdlet. For example, here is how you would query against your domain for all user accounts:

Get-ADUser -Filter * -SearchBase "DC=ad,DC=company,DC=com"

If you wanted to query for all of the user accounts with the last name "Collicott", you would run the following:

Get-ADUser -Filter {Surname -eq "Collicott"} -SearchBase "DC=ad,DC=company,DC=com"

To export the e-mail addresses for all user accounts to a CSV file, you could run the following:

Get-ADUser -Filter * -SearchBase "DC=ad,DC=company,DC=com" -Properties mail | Select mail | Export-CSV "Email Addresses.csv"

You can also find additional examples by viewing the help on the cmdlet:

Get-Help Get-ADUser -examples

Recent Blog Posts

lunavi logo alternate white and yellow
3.13.2025
3
.
12
.
2025
Unlocking the Power of Azure Managed Services with Lunavi

Cloud computing has become the backbone of modern business, offering agility, scalability, and cost efficiency. But managing cloud environments while keeping costs under control and security airtight? That’s a challenge. Azure Managed Services streamline cloud operations, helping businesses optimize spending, enhance security, and future-proof applications. Lunavi provides the expertise and tools to make it happen—so you can focus on growth instead of IT headaches.

Learn more
lunavi logo alternate white and yellow
2.11.2025
2
.
7
.
2025
The Future of Test Automation: Key Trends Shaping 2025 and Beyond

Software testing has gone from a chore to a game-changer, thanks to automation. But in 2025, sticking to old methods means falling behind. Stay ahead by embracing the future of test automation—let’s explore the key trends shaping what’s next.

Learn more
lunavi logo alternate white and yellow
2.11.2025
1
.
23
.
2025
The Importance of Cross Browser Testing

Making sure users have a smooth experience across all these platforms is crucial for businesses to stay competitive. Cross-browser testing is now a key part of modern development. It helps teams find and fix problems like layout issues, broken features, or slow performance before users are affected. Let’s look at why cross-browser testing matters and explore tools that make it easier to get the job done.

Learn more