How to get AD users by department

Last updated on:

Getting a list of users by department is one of the most common AD reporting tasks that admins perform that admins perform to build organization charts, run license audits, conduct access reviews, and verify HR sync. There are three practical ways to do it: using the Get-ADUser PowerShell cmdlet, the Active Directory Users and Computers (ADUC) console, and ADManager Plus.

What is the department attribute in AD?

In AD, department is a single-valued string attribute on the user object. It is populated either manually through the ADUC Organization tab or programmatically, usually by an HR-to-AD sync. The attribute is widely used as a grouping field for reporting, dynamic distribution lists, and licensing logic. Even though it's queried frequently, department is not part of the default property set returned by Get-ADUser, which is the single biggest source of confusion when results come back blank.

  • PowerShell
  • ADUC
  • ADManager Plus
  • Why ADManager Plus
  • FAQ
 

Prerequisites

Before you run the Get-ADUser cmdlet, confirm the following:

  • The Active Directory module for Windows PowerShell is installed.
  • The Active Directory module is imported in your session. If not, import it using: Import-Module ActiveDirectory.
  • Your account has read permission on the user objects you intend to query.
  • Ensure the execution policy permits running scripts.

Retrieve the department attribute for an AD user

Get-ADUser returns only a small default property set, including distinguishedName, Enabled, givenName, Name, ObjectClass, ObjectGUID, sAMAccountName, SID, Surname, and UserPrincipalName. Department is not in that list, so you must request it explicitly with -Properties.

$user = Get-ADUser -Identity 'sjacobs' -Properties Department, Title, Manager
if ([string]::IsNullOrEmpty($user.Department)) {Write-Host "$($user.Name) has no department assigned."} else {[PSCustomObject]@ { Name = $user.Name sAMAccountName = $user.sAMAccountName Department = $user.Department Title = $user.Title }}

Filter users by department with -Filter

The -Filter parameter uses PowerShell Expression Language and runs server-side, so it's far faster than piping to Where-Object.

# All users whose department is exactly "Sales"
Get-ADUser -Filter "Department -eq 'Sales'" -Properties Department |
Select-Object Name, sAMAccountName, Department
# Wildcard match — any department starting with "IT"
Get-ADUser -Filter "Department -like 'IT*'" -Properties Department |
Select-Object Name, sAMAccountName, Department
# Multiple departments using -or
Get-ADUser -Filter "Department -eq 'Sales' -or Department -eq 'Marketing'" `
-Properties Department |
Select-Object Name, sAMAccountName, Department

Structure the output with Select-Object and Format-Table

By default, Get-ADUser returns rich objects. Use Select-Object to pick columns for reporting and Format-Table for clean console output.

Get-ADUser -Filter "Department -eq 'Engineering'" -Properties Department, Title, Manager |
Select-Object Name, sAMAccountName, Department, Title |
Format-Table -AutoSize
Name sAMAccountName Department Title
---- -------------- ---------- -----
Steve Jacobs sjacobs Engineering Senior Platform Engineer
Mark Jacob mjacob Engineering DevOps Engineer

Scope a query to an OU with -SearchBase

For large directories, restricting the query to a specific OU is essential for performance.

# Get every user under OU=Sales,DC=skyy,DC=com with their department
Get-ADUser -SearchBase "OU=Sales,DC=skyy,DC=com" `
-Filter * `
-Properties Department |
Select-Object Name, sAMAccountName, Department
# Limit to one OU level (no nested OUs) with -SearchScope OneLevel
Get-ADUser -SearchBase "OU=HQ,DC=skyy,DC=com" `
-SearchScope OneLevel `
-Filter "Department -eq 'Finance'" `
-Properties Department

If you need to pull users across multiple OUs in a single run, see Get-ADUser list from multiple OUs.

Export department data to CSV

Pipe Get-ADUser straight to Export-Csv and never through Format-Table first.

Get-ADUser -Filter * -Properties Department, Title, Manager |
Select-Object Name, sAMAccountName,
@{Name='Department'; Expression={ if ($_.Department) { $_.Department } else { 'Unassigned' } }},
Title,
@{Name='Manager'; Expression={ (Get-ADUser $_.Manager -ErrorAction SilentlyContinue).Name }} |
Export-Csv -Path "C:\Reports\skyy-users-by-department.csv" -NoTypeInformation -Encoding UTF8

The calculated Department column substitutes Unassigned for blanks, so the report stays clean. For more CSV-driven patterns, see Get-ADUser with Import-Csv module.

Fetch department report for an entire OU or domain

Use a complete, parameterized script that imports the module, scopes to an OU, filters by department, resolves manager names, handles null values, and exports to CSV.

<#
.SYNOPSIS
Generate a department-based user report from Active Directory.

.EXAMPLE
.\Get-DepartmentReport.ps1 -Department 'Engineering' -OU 'OU=HQ,DC=skyy,DC=com' `
-OutputPath 'C:\Reports\engineering.csv'
#>
param(
[string]$Department,
[string]$OU,
[string]$OutputPath = "C:\Reports\skyy-department-report.csv"
)

Import-Module ActiveDirectory
# Build query parameters dynamically
$params = @{
Properties = 'Department','Title','Manager','EmailAddress','Enabled'
}
if ($Department) { $params.Filter = "Department -eq '$Department'" } else { $params.Filter = '*' }
if ($OU) { $params.SearchBase = $OU }

# Resolve and export
Get-ADUser @params |
Select-Object `
Name,
sAMAccountName,
UserPrincipalName,
@{N='Department'; E={ if ($_.Department) { $_.Department } else { 'Unassigned' } }},
Title,
@{N='Manager'; E={ (Get-ADUser $_.Manager -ErrorAction SilentlyContinue).Name }},
EmailAddress,
Enabled |
Sort-Object Department, Name |
Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8

Write-Host "Report saved to $OutputPath" -ForegroundColor Green

Update the department attribute with Set-ADUser

Filtering is half the job; admins also need to set or change the value. Use Set-ADUser for single updates and a CSV-driven loop for bulk changes.

# Single user — move Mark Jacob to the Platform team
Set-ADUser -Identity 'mjacob' -Department 'Platform'
# Bulk update from a CSV with headers: sAMAccountName, Department
Import-Csv -Path 'C:\Imports\department-changes.csv' | ForEach-Object {
Set-ADUser -Identity $_.sAMAccountName -Department $_.Department
Write-Host "Updated $($_.sAMAccountName) -> $($_.Department)"
}

Limitations of the PowerShell approach

  • No native scheduling or distribution: Task Scheduler can run a script, but emailing the result, archiving it, or piping it to a ticketing system is extra plumbing each time.
  • No approval workflows: Set-ADUser changes are immediate; and there is no built-in two-step approval for sensitive bulk modifications.
  • Manager resolution is slow: Every Get-ADUser lookup for a manager DN adds a round trip, and reports with thousands of users get noticeably slow.

Viewing department in ADUC

ADUC shows the department field on the user's Organization tab. To view the department attribute of a user:

  1. Press Win + R, type dsa.msc, and launch ADUC.
  2. In the left pane, expand your domain and the OU containing the user.
  3. Right-click the user and choose Properties.
  4. Switch to the Organization tab.
  5. Read the Department value. The Manager field on the same tab shows the user's manager.

Modifying a user's department in ADUC

In the same Organization tab, type a new value in the Department field and click OK. The change is immediate. Note that there is no undo, no approval gate, and no built-in audit note attached to the change.

Get a user's department in ADManager Plus

ADManager Plus, an AD reporting tool, comes with predefined user reports that return every user across one OU, multiple OUs, or the entire forest without writing or maintaining any PowerShell scripts. The reports are point-and-click; schedulable to email recipients on a recurring basis; exportable to CSV, PDF, XLSX, and HTML formats; and backed by an audit trail.

Steps to view a user's department

  1. Log in to ADManager Plus.
  2. Go to Reports > User Reports > General Reports > All users.
  3. Select the domain and click Generate. The report lists every user with their department, title, manager, last logon, status, and other configurable columns. Add or remove columns to view the desired information.
  4. Use Export as to export the report, or click Schedule Reports to email it to stakeholders.
  5. You can also save and run this as a custom report.
The All Users report showing the Department column, with options to schedule and export the report

Bulk-update the department attribute without scripting

Once you have a list of users to reassign, use ADManager Plus' bulk user modification feature to change the department attribute for many users at once from a CSV, or pick users directly from a generated report.

Why teams choose ADManager Plus over PowerShell and ADUC for department-wide reporting

  • No scripting required: Department reports, filters, and exports are generated through the web console and anyone in IT can use them, not just technicians.
  • Report scheduling: Send the department report to other teams at a desired frequency.
  • Role-based delegation: Delegate reports to a help desk technician without granting full domain admin privileges.
  • Approval workflows: Help desk technicians can submit department changes that route through configurable approval steps.
  • Cross-OU and multi-domain reports: A single report can span multiple OUs and even multiple domains, eliminating the multi-script work PowerShell otherwise requires.

FAQ

Get-ADUser is the PowerShell cmdlet, supplied by the Active Directory module for Windows PowerShell, that retrieves one or more user objects from AD. You query by identity, filter expression, or LDAP filter, and you ask for additional attributes with -Properties.

The most common reason is that -Properties Department was not specified, since Department is not in the default property set. Other causes include: the user was created without the field populated; HR sync hasn't run; or the attribute was cleared during a role change. For a deeper pattern on detecting missing attributes, see filtering Get-ADUser by null attribute.

Run the Get-ADUser -Filter * -Properties Department | Select-Object Name, sAMAccountName, Department. For domain-wide bulk exports, see Get all AD users with PowerShell.

For a single user, run:

Set-ADUser -Identity 'sjacobs' -Department 'Marketing'

To clear it, use -Department $null. For bulk changes, import a CSV and loop with Set-ADUser, or use bulk user modification in ADManager Plus to do it with approval workflows.

You can wrap a script in Task Scheduler, but you'll have to build the email delivery, archival, and retention pieces yourself. ADManager Plus has built-in report scheduling that emails department reports as CSV, PDF, or other attachments.

Get AD users by department — the no-script way

The one-stop solution to Active Directory Management and Reporting
Email Download Link Email the ADManager Plus download link