Add an Email Address to Active Directory User

2 min read
Add an Email Address to Active Directory User
Workspace ONE is setup to use the email address field for account creation. Someone forgot to add an email address.

VMware Workspace ONE

You are a special breed, how can I say it, with unique aspects that differ from Citrix Gateway & StoreFront. At a place I once found my talents employed we had Workspace ONE setup to sync with Active Directory and if an active directory user name had a valid formatted email address in the email address field Workspace ONE would create a login account for that user.

Users Got No Email Address

Then you’d find others in the organization creating user accounts for either employee’s, contractors, test accounts, etc. and leaving the email address blank then attempting to use that account to login Workspace ONE. The result is they couldn’t login.

Mind you this got to the point where there was many like this. A quick solution is found in the powershell script below. Keep in mind Workspace ONE didn’t require the email addresses to be valid, only that they where in an email addresses format, ie someone@company.com.

Make Email Address Appear

The version below will take the users.txt file and set the email address for every given user. This is what I had done in the past, get all user names without email address, run the commands to add an email address as: username@company.com.

Don’t forget to sync Workspace ONE after you do this. I’ve seen setups where active directory sync takes place once a hour and another once every 24 hours so you may want to run a manual sync after you add the email addresses to speed things up.

Best Regards
Michael Wood


#---------------Display Banner--------------------

Write-Host ""
Write-Host "╒══════════════════════ " -NoNewLine
Write-Host "EMAIL FOR MULTIPLE AD ACCOUNTS " -Foreground Cyan -NoNewLine
Write-Host "═══════════════════════╕"
Write-Host "│                                                                             │"
Write-Host "│" -NoNewLine
Write-Host " Adds an email address to all AD Accounts listed in the file USERS.TXT       " -Foreground Magenta -NoNewLine
Write-Host "│"
Write-Host "│                                                                             │"
Write-Host "│" -NoNewLine
Write-Host " Helpful as email address are required for Workspace Account creation.       " -Foreground Magenta -NoNewLine
Write-Host "│"
Write-Host "│                                                                             │"
Write-Host "╘═════════════════════════════════════════════════════════════════════════════╛"
Write-Host ""
Read-Host "Press Enter to begin running the request"
Write-Host ""
Write-Host " Processing..."


#---------------Variables-------------------------

$Users = Get-Content .\users.txt
$StartTime = Get-Date


#---------------Application--------------------

Foreach ($User in $Users) {

# CLS
Write-Host ""
Write-Host -Foreground Yellow " Currently work on $User processing..."

    # Set Variables
    $Email = $user + '@company.com'
    $EmailField = Get-ADUser -Identity $user -Properties EmailAddress | select EmailAddress

    # Execute Application
    $SetEmail = Set-ADUser -Identity $user -EmailAddress $email
    Write-Host -ForegroundColor Green " Email address added for $user!"

}


#---------------Good Bye Message---------------

$FinishTime = Get-Date
# CLS
Write-Host ""
Write-Host " ═════════════════ " -NoNewLine
Write-Host "EMAIL FOR MULTIPLE AD ACCOUNTS " -Foreground Cyan -NoNewLine
Write-Host "═════════════════"
Write-Host ""
Write-Host -ForegroundColor Green "Completed!"
Write-Host ""
Write-Host -ForegroundColor Cyan "Start Time:"
Write-Host "$StartTime"
Write-Host ""
Write-Host -ForegroundColor Cyan "Finish Time:"
Write-Host "$FinishTime"
Write-Host ""
Read-Host "Press any key to exit application"
Virtualize Brief


Follow