Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions scripts/spo-change-list-url/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,29 @@ $newListName = "Logo Universe"
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Get the SharePoint list
$list = Get-PnPList -Identity $oldListName

# Move SharePoint list to the new URL
$list.Rootfolder.MoveTo($newListUrl)
Invoke-PnPQuery

# Rename List
Set-PnPList -Identity $oldListName -Title $newListName
try {
# Get the list object
$list = Get-PnPList -Identity $oldListName -ErrorAction Stop

# Check if the target URL already exists
$existingFolder = Get-PnPFolder -Url $newListUrl -ErrorAction SilentlyContinue
if ($existingFolder) {
Write-Host "Error: A list or folder already exists at '$newListUrl'. Aborting." -ForegroundColor Red
return
}

# Move the list's root folder to the new URL
$list.RootFolder.MoveTo($newListUrl)
Invoke-PnPQuery
Write-Host "List URL successfully changed to '$newListUrl'." -ForegroundColor Green

# Rename the list display name
Set-PnPList -Identity $list -Title $newListName
Write-Host "List display name successfully changed to '$newListName'." -ForegroundColor Green

} catch {
Write-Host "An error occurred: $_" -ForegroundColor Red
}

```

Expand All @@ -50,6 +64,7 @@ Set-PnPList -Identity $oldListName -Title $newListName
| Author(s) |
|-----------|
| [Ganesh Sanap](https://ganeshsanapblogs.wordpress.com/about) |
| ojopiyo |

[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-change-list-url" aria-hidden="true" />
10 changes: 8 additions & 2 deletions scripts/spo-change-list-url/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"shortDescription": "This sample script shows how to change SharePoint online list URL and rename the list after list creation using PnP PowerShell",
"url": "https://pnp.github.io/script-samples/spo-change-list-url/README.html",
"longDescription": [],
"creationDateTime": "2023-03-22",
"updateDateTime": "2023-03-22",
"creationDateTime": "2025-12-11",
"updateDateTime": "2025-12-11",
"products": [
"SharePoint"
],
Expand Down Expand Up @@ -35,6 +35,12 @@
}
],
"authors": [
{
"gitHubAccount":"ojopiyo",
"company": "",
"pictureUrl": "https://avatars.githubusercontent.com/u/122151392?v=4",
"name": "ojopiyo"
},
{
"gitHubAccount": "ganesh-sanap",
"company": "",
Expand Down