[ ] Introduction
I have a lot of user at my Exchange, all users have more of one email, for O365 project I need assign one specific default email.
I prepared one list with a login name and the new default email account.
[ ] The script
**********************************
# Import AD Module
#Import-Module ActiveDirectory
#Si queremos hacer un BAckup antes:
#Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress > Backup
#Log
$LogFile = "C:\scripts\O365\EmailDefault\logUpdates.txt"
write-Host 'Starting to update AD Attributes.......' -NoNewline -ForegroundColor Yellow
write-Host "`r`n"
# Import CSV into variable $LIST_users
#fICHERO DE USUARIOS A ACTUALIZAR
$LIST_users = Import-Csv C:\scripts\O365\EmailDefault\UserList.TXT -delimiter ";"
# Loop through CSV and update users if the exist in CVS file
$LIST_users|Foreach{
Write $_.Login
Write-output "`n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++`r`n" >> $LogFile
Write-output $_.Login | out-file -filepath $LogFile -append
Write-output "`n====================================================================`r`n" >> $LogFile
Set-Mailbox $($_.Login) -Primarysmtpaddress $($_.DefaultAddress) -confirm:$false -Emailaddresspolicyenable $False 2>> $LogFile
}
Write-Host 'done!' -ForegroundColor Green
*********************************
[ ] The Log
For check I can verify my log ($LogFile = "C:\scripts\O365\EmailDefault\logUpdates.txt") with the results.
REF: https://technet.microsoft.com/es-es/library/hh847746.aspx
Check at Exhange 2007
by GoN | Published: November 16, 2017 | Last Updated:
No hay comentarios:
Publicar un comentario