How to change my domain name in sharepoint server 2019 using powersehll?

Tevon2.0 1,106 Reputation points
2023-10-19T21:06:23.46+00:00

I need my new domain name to change to RE-REK via powershell. How can I go about making this change for SharePoint server 2019? Account name will be RE-REK\upsync

User's image

Microsoft 365 and Office | SharePoint Server | For business
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-10-20T02:40:30.4+00:00

    Hi Tevon,

    To change the domain name in SharePoint Server 2019 using PowerShell, you can follow these steps:

    1. Download and install the latest SharePoint Server 2019 Management Shell.
    2. Connect to SharePoint Server 2019 as a farm administrator using the Connect-SPFarm cmdlet.
    3. Use the Set-SPAlternateURL cmdlet to add the new URL for the web application.
    4. Use the Set-SPSiteURL cmdlet to update the site collection URLs.
    5. Use the Move-SPUser cmdlet to update the user accounts to use the new domain name.

    Here is an example PowerShell script that you can use to change the domain name to RE-REK:

    # Connect to SharePoint Server 2019 as a farm administrator
    Connect-SPFarm -UserAccount "RE-REK\upsync"
    
    # Add the new URL for the web application
    Set-SPAlternateURL -Url "https://RE-REK.sharepoint.com" -Zone "Default"
    
    # Update the site collection URLs
    Get-SPSite -Limit All | ForEach-Object {Set-SPSiteUrl $_.Url -Zone "Default" -Url ("https://RE-REK.sharepoint.com" + $_.ServerRelativeUrl)}
    
    # Update the user accounts to use the new domain name
    Move-SPUser -Identity "OLD_DOMAIN\username" -NewAlias "RE-REK\username"
    

    Note that this process may take several hours to complete depending on the number of sites and users that you have. It is recommended to perform this change during a period of low usage and to inform users to avoid accessing SharePoint content during the change. Additionally, any actions that create new sites or users will be temporarily blocked during the rename.

    For your references:

    Set-SPAlternateURL

    Set-SPSiteURL

    Move-SPUser

    Hope this helps.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.