• Uncategorized
  • 1

Changing domain name and user attributes

When companies changing the names or users need to have a different emailaddress and you have synced your on-prem Active Directory to Azure Active Directory you need to change the users attributes on-prem.

It could be a time consuming job to do this manually for several users, but Microsoft didn’t create PowerShell for nothing 🙂

I have a small script in which I created a function called New-DomainForADUser that will changing the following user attributes:

  • Emailaddress
  • proxyAddresses
  • UserPrincipalName

If you are going to change from one domain to another this simple script will help you. And if you are using Office 365 (who doesn’t?!) you need to first verify the domain to Office 365 – don’t forget that part!

Start by adding the UPN Suffix, you can do it either with PowerShell or the Active Directory Domains and Trusts.

Then use the Get-ADForest again to retrieve all the UPN Suffixes.

Now it’s time to change the attributes for specified users i an Organizational Unit in Active Directory.

Here’s the script that’s running.

When you have done that, you can either wait for the AAD Connect sync to kick in or you can force it with:

Don’t forget to notify your users that when they are logging in to the Office 365 Portal, they need to logon with the new username (the new UserPrincipalName).

You also need to create a new Outlook Profile for your users, this can be automated with a simple logon script that you deploy with Group Policy.

Here’s one example to automate this process: https://misstech.co.uk/2015/01/18/office-365-outlook-profiles-in-a-cutover-migration/

Note: If the users username won’t change, you can manually force it with:


You may also like...

1 Response

  1. CMP says:

    Hi, i saved the script as Set-NewDomainForADUser.ps1 and ran it with: Set-NewDomainForADUser.ps1 -oldSuffix “domain.com” -newSuffix “domain.nu” -OU ThePathToOU” but nothing happened, am i missing something?

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: