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.
Update all users with blank emails via PowerShell
March 19, 2017
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
}
You May Also Like