Not every account needs an email address, or sometimes the provisioning script might not populate the email address.
My bosses wanted an "empty email address" report, so I needed a way to export a list of users with empty email address field, and their respective OU's.
Since this is an Accounts Forest (with no Exchange) we'll have to use Active Directory PowerShell cmdlets...which aren't as easy to use to grab recipient information.
So, here's a quick one-liner that will grab all ADUsers with no email address populated; the full path of the Organizational Unit they live in; and export that list to a CSV file.
Fire up Active Directory Module for Windows PowerShell and run the following cmdlet:
Get-ADUser -Filter {EmailAddress -notlike "*"} -Properties EmailAddress | Select-Object Name,@{n='OU';e={$_.canonicalname -replace "/$($_.cn)",""}} | Export-Csv "C:\Temp\EmptyEmailAddresses.csv"
**Note** Change the "C:\Temp\EmptyEmailAddresses.csv" path to wherever want to save the csv.
Your csv output will look like so:
| ||||||||||||
No comments:
Post a Comment