Update all blank email addresses in AD with PowerShellUpdate all blank email addresses in AD with PowerShell
Update all users with blank emails via PowerShell
John Savill
March 19, 2017
1 Min Read
![Update all blank email addresses in AD with PowerShell Update all blank email addresses in AD with PowerShell](https://eu-images.contentstack.com/v3/assets/blt07f68461ccd75245/blta833eb400514a93a/661cf77178878c35a7d31a5f/powershell_0_0_4.png?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
Q. How can I set the email address of all users with a blank email address to that of their UPN?
A. Using PowerShell its very easy to change the email address of every user with a blank email to that of their UPN:
$accounts=Get-ADUser -Filter * -Properties mail | where {$_.mail -eq $null} #| select sAMAccountName, UserPrincipalName, mail
foreach($account in $accounts)
{
$account | Set-ADUser -EmailAddress $account.UserPrincipalName
}
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like