How to List Active Directory Users by Department

by Robert Allen

In this guide, I’ll show you how to list Active Directory users by Department. I will include examples for both Active Directory and Azure Active Directory.

Topics in this article

Let’s get started.

List Active Directory Users by Department with PowerShell

In this example, I’ll display all users and list only the displayname and department attributes.

get-aduser -filter * -properties displayname, department | select displayname, department
list active directory users by department powershell

Get a Count of AD Users in each Department

In this example, I’ll get all departments and the count of users in each department. This is useful to see how many users you have in each department.

get-aduser -filter * -properties * | group-object -property department
powershell count of users in each department

Search for Users in a Specific Department

To get users from a specific department you can use the -filter parameter.

In this example, I’ll list all users that are in the “Accounting” department.

Get-ADUser -Filter {department -eq "Accounting"} -property department | Select samaccountname, department
powershell search for users in specific department

Easily List AD Users by Department with AD Pro Toolkit

An alternative to PowerShell is to use a graphical tool that doesn’t require any scripting. In this example, I’ll use the AD Pro Toolkit to get all users and their departments.

Open the toolkit, Click on Export Users and click Run.

By default, this tool will display several user attributes including the OU and group membership.

You can add or remove user attributes by clicking the columns button.

To export the results to CSV click the export button.

List Azure Users by Department

To list Azure users by department we will use the Get-MgUser PowerShell cmdlet.

This cmdlet requires the Microsoft graph module to be installed. To learn more about this refer to the article get-mguser all properties.

Below is the command to list Azure users by the department.

get-mguser -All -Property displayname, department | select displayname, department
azure list users by department

Get Azure Users in Specific Departments

In this example, I’ll search for Azure users in the Accounting department.

get-mguser -filter "department eq 'Accounting'" -Property displayname, department | select displayname, department
azure search users in specific department

I hope you enjoyed this article. If you have questions post them below.

Related Content

Recommended Tools

  • AD Cleanup Tool - Find stale and inactive user and computer accounts in Active Directory. Export, disable, move or delete the stale accounts to increase security.
  • AD User Creation Tool - Bulk import or update Active Directory user accounts. Add users to groups, import into OUs, set multiple attributes and more.
  • NTFS Permissions Tool - Scan and audit NTFS folder permissions. See which users and groups have access to what.
  • AD Reporting Tool - Over 200 reports on users, computers, groups, OUs and more. Customize reports or create your own reports with the report builder.

Leave a Comment