SharePoint Online: Change Site Collection URL using PowerShell

Requirement: Change the Site Collection URL in SharePoint Online.

How to Change the SharePoint Site URL?

Sometimes, you may have to change a site’s name and URL after creating it. Perhaps you’ve migrated to a new domain, changed the organization’s name or name of your department/project, restructuring, 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 for your tenant, 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.

Change the SharePoint Site Address: Step by Step

To change the URL of the existing SharePoint Online site, follow these steps As a Global Administrator or SharePoint Administrator:

  1. Login to the 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

Site URLs can be changed 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 SharePoint site, It 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! Please note, It is important to note that any links or bookmarks to the old URL will no longer work and will need to be updated.

#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

Overall, using PowerShell to change the URL of a SharePoint Online site collection is an efficient and straightforward way to update the URL of your site collection.

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 automatically update the site name! 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.

Conclusion

In conclusion, changing the URL of a SharePoint Online site collection can be accomplished using SharePoint Admin Center or PowerShell. By using the Connect-SPOService cmdlet to connect to SharePoint Online and the Start-SPOSiteRename cmdlet to change the URL of the site collection, you can easily update the URL of your SharePoint Online site collection.

It’s important to note that you should be cautious when changing the SharePoint site address because this process may break links and affect the functionality of the site. Before proceeding, you should make sure to test the process on a test environment, and also make sure that you have a backup of the site collection. Additionally, it’s important to update any hard-coded links or references to the site collection URL in any external systems and applications that rely on it. It is recommended that users be informed of the change and that any necessary links or bookmarks be updated.

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 to right-click on your desired File and Choose the “Rename” option. In the Rename pop-up, provide a new name for the file 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

Does renaming a SharePoint site change the URL?

No! Updating the site title from site settings or SharePoint Admin Center (or PowerShell) doesn’t change the site URL.

How Do I Remove a Redirect Site in SharePoint Online?

To remove a redirect in SharePoint Online, you can use the PowerShell cmdlet “Remove-SPOSite”. For example, you can run the command Remove-SPOSite -Identity [RedirectSiteURL] to delete the redirect.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “SharePoint Online: Change Site Collection URL using PowerShell

  • Hi, I changed the address of a team’s main library; on the main channel everything is ok, on the private ones I can’t (if I open them it opens with the old name); Can the address of the private teams also be changed so as to reflect those of the general team?

    Reply
  • Hi,
    Editing the URL from the Admin center has worked fine for me previously, but for the past 2 months the option to edit any URL for any type of site is now greyed out. Do you know what might be causing this?
    Thank you

    Reply
    • Yes! Here are the possible root causes:
      1. If a site is under retention policy – You can’t change the site URL!
      2. The Publishing feature is activated (or was previously active).
      3. A site with more than 15 million documents.
      4. Certain site templates like “Project Site” are not supported.

      Reply

Leave a Reply

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