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:
- Login to the Modern SharePoint Admin Center >> Click on “Active Sites” under the “Sites” section.
- Select the site collection you want to rename and open its properties pane.
- 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.)
- 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!
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.
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!)
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.
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?
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 URL of a SharePoint Online site collection, 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 to inform users of the change and update any necessary links or bookmarks.
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
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?
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
No! Updating the site title from site settings or SharePoint Admin center (or PowerShell) doesn’t change the site URL.
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
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.