Find users without a department
Documentation: Microsoft Learn
Enabled accounts come back with the Department attribute requested, the middle stage keeps the ones where it is empty, and the output is narrowed to the account name.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Illustrative rows: Department is empty for the returned accounts.
SamAccountName Name -------------- ---- msen Mira Sen adas Asha Das
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-ADUser -Filter "Enabled -eq $true" -Properties Department | Where-Object { -not $_.Department } | Select-Object SamAccountName,Name- Stage 1Get-ADUser
-Filter -Properties - Stage 2Where-Object
Positional values or no named parameters - Stage 3Select-Object
Positional values or no named parameters
How it works
Enabled accounts come back with the Department attribute requested, the middle stage keeps the ones where it is empty, and the output is narrowed to the account name.
Adapting it
Substitute Title or EmployeeID for Department depending on which attribute your dynamic rules actually key off; the shape of the query does not change at all.
Requirements
ActiveDirectory module.
If the result is unexpected
The department report returns many accounts that appear correctly assigned elsewhere.
Department may be stored in HR or cloud data without being populated in the queried AD attribute.
- Inspect the requested Department property and compare a sample with the authoritative source.
Validate the result
The report identifies genuinely empty AD department values using the stated scope.
Keep the check reliable
Define which system supplies Department and reconcile changes through that system.