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?
Previously, We had to create a new site collection and run a migration tool to copy all contents from old site to new site. Well, not anymore! 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 "Edit" link next to site URL. Provide a new URL and hit "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 change the URL of an existing site collection URL and Title from "Suppliers to "vendors".
rename site collection in sharepoint online

Please note, there are some side effects flows explained in Microsoft article here https://docs.microsoft.com/en-us/sharepoint/change-site-address if you rename a site collection, like you'll loose all files in recycle bin.
SharePoint Online: Change Site Collection URL using PowerShell SharePoint Online: Change Site Collection URL using PowerShell Reviewed by Salaudeen Rajack on September 18, 2019 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.