Find enabled users without email
Documentation: Microsoft Learn
Enabled users are retrieved with the mail attribute requested explicitly, and the intent of the middle stage is to keep only accounts where mail holds nothing.
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
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 mail | Where-Object { -not $_.mail } | Select-Object SamAccountName,Name,DistinguishedName- 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 users are retrieved with the mail attribute requested explicitly, and the intent of the middle stage is to keep only accounts where mail holds nothing. The projection carries DistinguishedName alongside the names so you can tell which OU each gap came from.
Adapting it
In a hybrid environment, test proxyAddresses rather than mail, since Exchange-managed addresses land there first and the mail attribute can lag behind by a sync cycle.
Requirements
ActiveDirectory module.
If the result is unexpected
The report lists users who have a mailbox but no AD email value.
The on-premises mail attribute and the mailbox or cloud address are related but not interchangeable data sources.
- Inspect the mail property on a sample user and compare it with the authoritative mail system.
Validate the result
The report clearly identifies missing AD mail values rather than claiming that no mailbox exists.
Keep the check reliable
State which directory attribute the report evaluates and who owns its population.