Created
May 13, 2020 16:55
-
-
Save azure365pro/99fe2f090516fab9de88ad7c7da38598 to your computer and use it in GitHub Desktop.
Change User Principal Name equals Email Address Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE : Before running the script run below commands to check which are the mailboxes it will apply to | |
# Get-Mailbox -ResultSize Unlimited | Where-Object {$_.Primarysmtpaddress -ne $_.UserPrincipalname} | |
# Get-Mailbox -ResultSize Unlimited | Where-Object {$_.Primarysmtpaddress -ne $_.UserPrincipalname} | ForEach-Object {Set-Mailbox $_.identity -UserPrincipalName $_.Primarysmtpaddress -whatif} | |
# Include Exchange Powershell Module | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn | |
#Lists All Mailboxes | |
#Checks Email and UPN are same | |
#Lists which are not email | |
#Applies UPN Matching email | |
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.Primarysmtpaddress -ne $_.UserPrincipalname} | ForEach-Object {Set-Mailbox $_.identity -UserPrincipalName $_.Primarysmtpaddress} | |
# Exit Exchange Powershell Module | |
Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment