Update 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

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(s)

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