Change the URL of a list in SharePoint Online with PowerShell
Overview
Changing the URL of a list in SharePoint Online can be done in SharePoint Designer but will be discontinued in the future.
This article will show how to change the URL of a listing with PnP PowerShell.
For an overview of PnP PowerShell, see the following link.
PnP PowerShell overview
Prerequisite
This article assumes that PnP PowerShell is installed.
URL change of a list
Connect to a site with a list of URL change targets
Connect to the site with Connect-PnPOnline cmdlet.
1Connect-PnPOnline -Url "https://sample.sharepoint.comsites/sample" -Interactive
Confirm the list
Get-PnPList cmdlet allows you to list a list. Here, the URL of sampleList is stored in a variable to be changed.
1Get-PnPList
2
3Title Id Url
4----- -- ---
5Documents 345f5198-cc53-4c1f-81a4-cc2c6874e12d /sites/sample/Shared Documents
6sampleList 2b2010e7-bf28-4f3f-aebb-5fea30d609e9 /sites/sample/Lists/sampleList
7
8$list = Get-PnPList -Identity "sampleList"
Change URL
The URL will be changed to the part after the site name. In this case, the following red part applies.
/sites/sample/Shared Documents
/sites/sample/Lists/sampleList
As previously mentioned、here we change the URL of sampleList.
1$NewListURL = "Lists/NewList"
2$list.RootFolder.MoveTo($NewListURL)
3
4Invoke-PnPQuery
Confirm that the URL has changed
Get-PnPList cmdlet confirms that the URL has been changed.
*If Url is the same as Title, Title is also changed.
1Get-PnPList
2
3Title Id Url
4----- -- ---
5Documents 345f5198-cc53-4c1f-81a4-cc2c6874e12d /sites/sample/Shared Documents
6NewList 2b2010e7-bf28-4f3f-aebb-5fea30d609e9 /sites/sample/Lists/NewList