Skip Ribbon Commands
Skip to main content

How do I change the domain name from vanity domain name to .onmicrosoft.com domain name, via PowerShell?

Last Update: 7/21/2017 11:29 AM
This article has been moved to our new Help Center. Please update your bookmarks.

​​​How do I change the domain name from the vanity domain name to .onmicrosoft.com domain name, via PowerShell?

Answer:

The following is an example PowerShell script to perform this action. You will need to replace the domain names in this example with your actual domain names.

$AdUsers = Get-ADUser -filter {UserPrincipalName  -like "*@mining88.com"} -Properties *
 
 
foreach ($user in $AdUsers)
{
    $upn = $user.UserPrincipalName
    $newupn = $upn -replace "@amining88.com", "@mining88.onmicrosoft.com"
    $alias = "smtp:$newupn"
 
    Set-ADUser $user -add @{proxyaddresses=$alias}
 
}

 

​​