Query For User Accounts In Active Directory With PowerShell - Lunavi

Solutions

Infrastructure Services

Azure Cloud Migration

Move your infrastructure to Azure with our expertise.

Colocation

Leverage our geographically diverse datacenters.

Lunavi Hybrid/Private Cloud

Our private or hybrid cloud solutions are feature-rich and backed by experts.

Critical Workload Management

Ensure maximum uptime with our multi-redundant facilities

Managed Services

Azure Managed Cloud

Want to save on IT costs? Look no further.

Managed Backup

Ensure that your data stays safe no matter the incident.

Disaster Recovery

Get business-critical data back fast, and reduce downtime.

Managed Security

Managed Firewall, Endpoint Protection, Reports and more.

Data & AI Solutions

Data Modernization

Unify your data and gain the competitive edge.

Machine Learning Data Platform

Develop a platform that showcases key insights day after day.

AI Predictive Data Analytics

Leverage AI to identify threats or opportunities before they happen.

Data Discovery Accelerator

Get started with a quick Accelerator leveraging Microsoft Fabric.

AI & App Development

Intelligent App Development

Let our experts develop a next gen AI powered application.

Application Development

We've built hundreds of cloud or mobile applications. Let us build yours.

DevOps Solutions

We help dev teams, leveraging agile best practices, Github copilot and more.

Gen AI App Accelerator

Learn how AI can benefit your business with a Proof of Concept in weeks.

Industries

Industries

Healthcare

We are HIPAA compliant and ready to help your Healthcare IT needs.

Hospitality

We help Hospitality have better customer experiences through technology.

Finance

We help financial orgs with security, compliance, AI breakthroughs and more.

Manufacturing

We can help manufacturers save on IT and focus on their business.

Resources

Resources

Lunavi Blog

Get the latest insights from our experts.

Customer Stories

Check out our customer success stories.

Featured from Blog

Introducting AIaaS: Maintaining Effective AI Agents

Today, Intelligent Applications and AI Agents are where enterprises can unlock real value, but how do you ensure that your AI stays on track?

Read More >What AI Policies Can Learn from 30 Years of Tech Friction at Work

AI policies are repeating 30 years of workplace tech friction—here’s what history reveals about getting governance right.

Read More >See all articles About

About Us

About Lunavi

Learn about Lunavi, Our Leadership and more.

Careers

What's Next For you? Work with us! Find out more here.

Partners

Learn about our partnerships here, login to the partner portal, or sign up to become a partner!

Corporate Responsibility

Pursuing the right path for the future.

Support Request a ConsultationQuery for User Accounts in Active Directory with PowerShellImage

March 1, 2023

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
Related Topics:
DevOpsMicrosoft

Previous post

Quarterly Wrap Up: Top Data Center News

Next post

Quickly Adding Meeting Details to OneNote
Join our newsletter
We're always talking about what's next in technology. Thank you! Your submission has been received!Oops! Something went wrong while submitting the form.

We're here to help you tackle what's next in your digital journey.

SolutionsIndustriesContact UsCase StudiesBlogAbout usPartnershipsCareersFollow Us:© Lunavi, Inc. All Rights Reserved. 2025 Privacy Policy | Acceptable Use

Tag » Active Directory Search User Powershell