SharePoint Online: Change Site Collection URL using PowerShell

Requirement: Change 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, 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. To change the URL of the existing SharePoint Online site, follow these steps:

  • Login to Modern SharePoint Admin Center >>  Click on “Active Sites” under “Sites” section
  • Select the site
    collection you want to rename and open its properties pane.
    sharepoint online change site collection url powershell
  • 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.
    Change site URL in SharePoint Online
  • You’ll get a progress message next, saying: “Updating site address”. Wait for it to turn “Updated Site Address”. That’s all! Your site collection is renamed now!
    how to change sharepoint online site collection url

Changing site URL 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

Let’s rename a SharePoint Online site collection URL with 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 New site (without having to update their bookmarks!)

rename site collection in sharepoint online

Please note, there are some side effects flows explained in the Microsoft article here https://docs.microsoft.com/en-us/sharepoint/change-site-address if you rename a site collection like you’ll lose all files in recycle bin.

To rename a site title in SharePoint Online, refer: SharePoint Online: How to Rename a Site using PowerShell?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply