Author Posts

January 1, 2012 at 12:00 am

by Christopher.Ellis at 2013-04-26 10:07:43

I want to run a quick powershell script which reports all users names in our active directory with empty emailaddress field
I would start the command with get-aduser however the rest not known to me. List produced would be username Populate and emailaddress would be empty.
Thank you

by Christopher.Ellis at 2013-04-26 10:24:46

get-aduser -property 'emailaddress' | select-object -property name, emailaddress

I got this far, however if I wanted to state emailaddress = empty display name the above command gets all accounts

by Martin9700 at 2013-04-26 10:30:03

Kind of a goofy one, evidently Get-ADuser doesn't recognize the $null variable within a filter but I found this to work:

Get-ADUser -Filter {EmailAddress -notlike "*"} -Properties EmailAddress | Select Name

by Christopher.Ellis at 2013-04-26 10:41:29

Thank you

October 1, 2015 at 8:36 am

Instead of the '-notlike "*"' you could use '-le 0'

September 26, 2017 at 10:28 pm

I needed to do this too, but I needed a list of all the email addresses. I ended up using this:

Get-ADUser -Filter {EmailAddress -like "*@*"} -Properties * | Select Name, SamAccountName, EmailAddress | Sort Name | Export-csv C:\Scripts\users_with_email_addresses.csv 

September 27, 2017 at 7:11 pm

Hi Chris

Just run the command below, you will get all AD account with no an email address assigned.

Get-ADUser -Filter * -Properties mail | Where-Object{$_.mail -like ""} | Format-Table

#If you want to export the result to a csv file...
Get-ADUser -Filter * -Properties mail | Where{$_.mail -like ""} | 
Select Name,GivenName,Surname,Enabled,SID | Export-CSV C:\temp\AdUserList-noMail.csv -notype

I have tested it so this will work 🙂