Forum Discussion
gteibo1
Mar 05, 2020Copper Contributor
Migrate mailbox to another domain same Tenant
Hi, In our company, we bought a new domain and we want to move all of our existing mailboxes to the new one. I already have both domains registered in the same tenant. I mean support@contoso.c...
EvilSecurityFellow
Mar 10, 2020Copper Contributor
gteibo1Hi there!
Your description is a bit vague, lets see if i understood you correctly:
A)
You have a tenat X and you are NOT going to setup a new tenant but just register a DOMAIN in the existing tenant x and want to change the UPN so that the users receive mail with the new Domain name?
OR
B)
You want to physically move mailboxes between Tenants?
Two totally different things here, let me know what you actually want to achieve and am happy to help. Done some 300+ migrations so might be able to help you 🙂
EvilSecurityFellow
parsian2
Jul 04, 2024Copper Contributor
EvilSecurityFellow
A)
You have a tenat X and you are NOT going to setup a new tenant but just register a DOMAIN in the existing tenant x and want to change the UPN so that the users receive mail with the new Domain name?
exactly i want to do as you mentioned on point (A)
A)
You have a tenat X and you are NOT going to setup a new tenant but just register a DOMAIN in the existing tenant x and want to change the UPN so that the users receive mail with the new Domain name?
exactly i want to do as you mentioned on point (A)
- chrisslrothJul 04, 2024Brass ContributorHi gteibo1,
Change the UPN with Powershell:
# Define the new UPN suffix
$newUPNSuffix = "new-domain.com"
# Connect to Azure AD
Connect-AzureAD
# Get all users in Azure AD
$users = Get-AzureADUser -All $true
# Loop through each user and update their UPN
foreach ($user in $users) {
# Extract the username part from the current UPN
$username = ($user.UserPrincipalName).Split('@')[0]
# Construct the new UPN
$newUPN = "$username@$newUPNSuffix"
# Set the new UPN
Set-AzureADUser -ObjectId $user.ObjectId -UserPrincipalName $newUPN
}
Write-Host "UPNs have been updated for all users."
After hat change der primary SMTP address:
# Define the new primary SMTP domain
$newPrimarySMTPDomain = "newdomain.com"
# Get all mailboxes
$mailboxes = Get-Mailbox -ResultSize Unlimited
# Loop through each mailbox and update the primary SMTP address
foreach ($mailbox in $mailboxes) {
$currentPrimarySMTP = $mailbox.PrimarySmtpAddress
$newPrimarySMTP = $mailbox.UserPrincipalName.Replace('@', "@$newPrimarySMTPDomain")
# Set the new primary SMTP address
Set-Mailbox -Identity $mailbox.Identity -PrimarySmtpAddress $newPrimarySMTP -EmailAddressPolicyEnabled $false
Write-Host "Changed primary SMTP address for $($mailbox.DisplayName) from $currentPrimarySMTP to $newPrimarySMTP"
}
Write-Host "Primary SMTP addresses have been updated for all mailboxes."