SharePoint Online: Change List or Library URL using PowerShell

Requirement: Change the URL of a List or Document Library in SharePoint Online using PowerShell.

How to Change the List URL in SharePoint Online?

In SharePoint Online, when you create a list, the list’s URL is automatically generated. This URL can be used to link or share the list with others. However, you may need to change the URL for different reasons, such as renaming the list or using a different name. This article will show you how to change a SharePoint Online list URL using PowerShell.

How do you change the URL of a SharePoint Online list? Because renaming a list title doesn’t change its URL! However, To change a List or Library URL in SharePoint Online, we can use File Explorer View, SharePoint Designer, or PowerShell! To change the document library URL using the Explore view:

  1. Open the Document Library in “File Explore View” (or Windows Explorer view!).
  2. Navigate One Level Up in the Explorer >> Select the Document Library to Rename.
  3. Press “F2” (or Right Click and choose “Rename”) >> Enter the new Name for your document library >> Hit “Enter”.
    SharePoint Online Change List URL using PowerShell

Using Explore View and SharePoint Designer to change the URL of a SharePoint list is explained in my other post for SharePoint On-Premises. It also applies to SharePoint Online: How to Change the URL of a List or Document Library in SharePoint? So here, let’s change the list URL in SharePoint Online with PowerShell.

SharePoint Online: Change List URL using PowerShell

How to change the URL of a document library in SharePoint Online? Well, let’s change the URL of a SharePoint Online document library from “Project%20Documentation” to “ProjectDocs” using PowerShell. To change the URL of the list, we have to call the “Rootfolder.MoveTo()” function with the New URL.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= ""
$ListName="Project Documentation"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
    #Get the List
    #sharepoint online change library url powershell   

    #Keep the List name as is
    Write-host -f Green "List URL has been changed!"
Catch {
    write-host -f Red "Error changing List URL!" $_.Exception.Message

This changes the URL of the given list or document library! We also change the list URL in SharePoint Online with PnP PowerShell with a few lines of script.

Rename Document Library URL using PnP PowerShell

Let’s use PnP PowerShell to change the document library URL in SharePoint Online:

#Set Parameters
$SiteURL = ""
$ListName = "Shared Documents"
$NewListURL = "documents"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the List
$List= Get-PnPList -Identity $ListName -Includes RootFolder

#sharepoint online powershell change list url

This moves the Root folder of a given list or document library to a new URL. By following the scripts provided in this article, you can easily change the URL of a list or library in SharePoint Online. Remember, the URL change of the existing list may break the links shared, workflows may fail, site customizations and custom solutions may not work as expected. If you want to change just the list title instead of the list URL, refer: SharePoint Online: How to Rename a List using PowerShell?

How to change the site URL in SharePoint Online?

To change the SharePoint site URL, Login to Modern SharePoint Admin Center >>  Click on “Active Sites” >> 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 to change site collection URL.
More info: Change SharePoint Online site URL

How do I make a document library as the home page in SharePoint Online?

Create a new site page, add a document library web part to it, and then set that page as the home page by going to Site contents >> Site Pages >> Select the Page and click on “Make homepage” from the toolbar. You can also use PowerShell to set a document library as the home page.
More info: Make document library as home page for SharePoint online site

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!

18 thoughts on “SharePoint Online: Change List or Library URL using PowerShell

  • This works brilliantly!
    Is it possible to also forward the old list URL to the new one?

  • Hello,
    Does the PowerShell script work for MFA enabled admins as well ?

    • Yes! Use the PnP PowerShell script with: Connect-PnPOnline -Url $SiteURL -Interactive

  • There is a side effect! List/Library can’t be restored once the url is changed.

  • ok..Thanks I will give try and let you know…Thanks a lot.

  • Thanks for quick reply.I am having list with around 1 million records so not able to move it. Any solution on it.

    • Delete the Items to recycle bin and then restore them back after the URL change is another alternative solution!

  • Thank you for this! It’s very useful. I do have a question though. I’ve been getting the following threshold error with a few large lists –

    Invoke-PnPQuery : The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

    I’ve seen some of your workarounds in other posts, but I’m not sure if any of them could be applied in this case. Any suggestions you have would be greatly appreciated.

    • did you get any solution?

      • For Larger lists and Libraries – The only workaround so far is: Moving Files outside the library, Perform the URL Change and then move back the files.

  • hello, I keep getting the following error: “Method invocation failed because [Microsoft.SharePoint.Client.Folder] does not contain a method named ‘MoveTo’.”

    Any ideas why?

    • “MoveTo” is a new addition in CSOM. Please update your CSOM assemblies/module.

    • Hi Salaudeen,

      I have updated the CSOM assemblies to the latest version. Still I am getting the above mentioned error.
      “Error changing List URL! Method invocation failed because [Microsoft.SharePoint.Client.Folder] does not contain a method named ‘MoveTo’.”

      What needs to be done here.

  • This command needs to be ran directly on the server? I’m using Office 365 SharePoint (not on-prem) and I’m having a hard time changing the URL of a list. The “open with explorer” no longer is available apparently in this new style.

    • Its PowerShell for SharePoint Online and can be installed from any client machine where SharePoint Client SDK or SharePoint Online PowerShell module is installed. “Open with Explorer” is moved under “Views” drop-down!

  • Man, you saved me hours of work! I had migrated a 50+ GB and 95.000 documents document library with a fixed URL (had removed blank spaces), but the original one was needed.
    Your script ended after timing out, but the doclib’s URL was successfully changed.
    Thank you very much.


Leave a Reply

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