Change list URL without losing /Lists/ in the URL??

%3CLINGO-SUB%20id%3D%22lingo-sub-2225130%22%20slang%3D%22en-US%22%3EChange%20list%20URL%20without%20losing%20%2FLists%2F%20in%20the%20URL%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2225130%22%20slang%3D%22en-US%22%3E%3CP%3EAll%20the%20PowerShell%20scripts%20I've%20found%20so%20far%20which%20provide%20a%20way%20to%20rename%20the%20URL%20of%20a%20List%20in%20SPO%26nbsp%3Bmove%20the%20list%20to%20the%20path%20%3CEM%3E%2Fsitename%2Fnewlistname%3C%2FEM%3E%20instead%20of%20maintaining%20%3CEM%3E%2Fsitename%3CSTRONG%3E%2FLists%2F%3C%2FSTRONG%3Enewlistname.%26nbsp%3B%3CBR%20%2F%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%23%20Set%20Parameters%0A%24SiteURL%20%3D%20%22https%3A%2F%2Fdomain.sharepoint.com%2Fsites%2FSupport%2F%22%0A%24ListGUID%20%3D%20%22fe67670b-1ae7-49e2-a20c-7b0c2dbe4b20%22%0A%24NewListURL%20%3D%20%22RenamedList%22%0A%0A%23%20Connect%20to%20PNP%20Online%0AConnect-PnPOnline%20-Url%20%24SiteURL%20-Interactive%0A%20%0A%23%20Fetch%20the%20list%20by%20it's%20GUID%20%0A%24list%20%3D%20Get-PnPList%20-Identity%20%24ListGUID%0A%0A%23%20Rename%20the%20list%20relative%20url%20to%20the%20url%20%0A%24list.Rootfolder.MoveTo(%24NewListURL)%0AInvoke-PnPQuery%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIs%20this%20a%20limitation%20in%20the%20way%20PNP%2FPowerShell%20works%3F%20Is%20there%20any%20way%20to%20do%20this%20without%20losing%20%2FLists%2F%20in%20the%20URL%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2225130%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Visitor

All the PowerShell scripts I've found so far which provide a way to rename the URL of a List in SPO move the list to the path /sitename/newlistname instead of maintaining /sitename/Lists/newlistname. 

 

# Set Parameters
$SiteURL = "https://domain.sharepoint.com/sites/Support/"
$ListGUID = "fe67670b-1ae7-49e2-a20c-7b0c2dbe4b20"
$NewListURL = "RenamedList"

# Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Interactive
 
# Fetch the list by it's GUID 
$list = Get-PnPList -Identity $ListGUID

# Rename the list relative url to the url 
$list.Rootfolder.MoveTo($NewListURL)
Invoke-PnPQuery

 


Is this a limitation in the way PNP/PowerShell works? Is there any way to do this without losing /Lists/ in the URL?

1 Reply

@andgoo 

This seems to work.  Change this:

$NewListURL = "RenamedList"

to include the Lists path:

 $NewListURL = "Lists/RenamedList"