SharePoint Online: Change Site Collection URL using PowerShell

Requirement: Change the Site Collection URL in SharePoint Online.

How to Change the Site URL in SharePoint Online?

Sometimes you may have to change the name of a site and URL after creating a site. Perhaps you’ve migrated to a new domain, changed the name of your department/project, or want to reorganize your site structure. Whatever the reason, we’ll walk you through the steps necessary to change your site URL in SharePoint Online.

In the past, We had to create a new site collection and run a migration tool to copy all contents from an old site to a new site to rename a site URL in SharePoint Online. Well, not anymore! Changing the SharePoint Online Site Collection URL is a relatively simple process that can be done in just a few minutes. If you have Global Administrator or SharePoint Online Administrator permissions, you can change the URL for the Microsoft 365 group-connected sites/non-group sites, Modern team sites, Communication sites, or Classic team sites. However, you can’t change the site address if the publishing feature is currently activated or was previously activated for the site, on sites with more than 15 million documents, Hub sites, and locked sites.

To change the URL of the existing SharePoint Online site, follow these steps:

  1. Login to the Modern SharePoint Admin Center >>  Click on “Active Sites” under the “Sites” section.
  2. Select the site collection you want to rename and open its properties pane.
    sharepoint online change site collection url powershell
  3. Click on the “Edit” link next to the site URL. Provide a new URL and hit the “Save” button. You’ll be prompted to enter the new name for the site. (The Site Name can be changed later by clicking Settings Gear Icon >> Site Information on the site.)
    Change site URL in SharePoint Online
  4. You’ll get a progress message next: “Updating site address”. Wait for it to turn to “Updated Site Address”. That’s all! Your site collection is renamed now!
    how to change sharepoint online site collection url

Changing site URLs can be done either through the SharePoint Admin Center or with PowerShell. Let’s see how to change the SharePoint Online site collection URL using PowerShell.

Important: “Start-SPOSiteRename” cmdlet is a new addition to the SharePoint Online PowerShell module. So, update your SharePoint Online PowerShell module first: “Update-Module microsoft.online.sharepoint.powershell”

SharePoint Online: Change Site Collection URL using PowerShell

Besides the SharePoint Online Admin center, We can also rename the site URL with PowerShell. Let’s rename a SharePoint Online site collection URL with the Start-SPOSiteRename cmdlet.

#Set Parameters
$AdminCenterURL="https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/suppliers"
$NewSiteURL = "https://crescent.sharepoint.com/sites/vendors"
$NewSiteTitle = "Vendors" 

#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#Get all site collections
$Sites = Get-SPOSite -Limit All | Select -ExpandProperty URL

If($Sites -notcontains $NewSiteURL)
{
    #Rename SharePoint Online site URL using PowerShell
    Start-SPOSiteRename -Identity $SiteURL -NewSiteUrl $NewSiteURL -NewSiteTitle $NewSiteTitle -Confirm:$false
}
Else
{
    Write-Host "New Site URL '$NewSiteURL' is not available!" -f Yellow
}

This script changes the URL of an existing site collection URL and Title from “Suppliers” to “Vendors”. When you change the URL of a site, SharePoint creates a copy of the site in the new URL and places a URL redirect on the old URL, so that anyone visiting the old URL will be redirected automatically to the site’s new URL (without having to update their bookmarks!)

rename site collection in sharepoint online

Please note that some side effects flow after the SharePoint site URL change.

  • The SharePoint data will remain intact when the site address changes.
  • OneDrive sync app continues to work after the site rename.
  • Sharing links will automatically redirect.
  • OneNote and iOS/Android mobile apps detect the change.
  • After the change, the new URL appears in the Recent Files section of the Office apps like Word, Excel, and PowerPoint web and desktop apps.

However, any custom solution’s URL dependencies may be affected. Any site customizations and embedded code that refer to URLs must be fixed after the site address change. Workflows to be republished, Power Apps- InfoPath forms have to be recreated. You’ll lose all files in the recycle bin if you rename a site collection. More on Microsoft article here https://docs.microsoft.com/en-us/sharepoint/change-site-address.

PnP PowerShell to Change the Site URL

Whether you need to change your site’s URL because you’ve changed the name of your team/project or reorganize your SharePoint sites, it’s easy to do in SharePoint Online. Just use the below PowerShell script, and you’ll have your site in a new URL up and running in no time!

#Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$OldSiteURL = "https://crescent.sharepoint.com/sites/ops"
$NewSiteUrl = "https://crescent.sharepoint.com/sites/operations"

#Connect to SharePoint Online from PnP PowerShell
Connect-PnPOnline -Url $AdminSiteURL -Interactive

#Change sharepoint online site url powershell
Rename-PnPTenantSite -Identity $OldSiteURL -NewSiteUrl $NewSiteUrl
Is it possible to change the domain name of the SharePoint Online? You may need it in merger and acquisitions. Yes, You can! Reference: Change your SharePoint domain name

Changing the site URL doesn’t update the site name automatically! So, How do I rename a SharePoint site in PowerShell? Sure, To rename a site title in SharePoint Online, use: SharePoint Online: How to Rename a Site using PowerShell?

How do you change the URL of a SharePoint Online list?

To change a list or document library URL in SharePoint Online, you can use these methods: Rename a list URL with File Explorer View, SharePoint Designer, or PowerShell!
More info: SharePoint Online Change List URL

How do I rename a file in SharePoint Online?

The quickest way to rename a document is, Right-click on your desired File and Choose the “Rename” option. Provide a new name to the file in the Rename pop-up and click Save. You can also rename files on SharePoint Online using PowerShell!
More info: How to Rename a document in SharePoint Online?

How do I change the Subsite URL in SharePoint?

To change the subsite address in SharePoint Online, follow these steps: Click on Settings >> “Site Information” and then “View All Site Settings”. Click on “Title, description, and logo” under the “Look and Feel” group, Enter the new URL for the subsite and click on “OK”. You can also use PowerShell to update the site address.
More info: SharePoint Online change subsite URL

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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