Updating the Url Names (Unique Names) of Lists or Libraries on SharePoint Online
Hello friends, today I will talk about a nice method that is very troublesome for sharepoint on prem users, but has a solution on the sharepoint online side.
As you know, when you create a list or library on sharepoint, the first name you give is defined as the url address and unique name for your list. You cannot change this later, you have to delete the list and create it again. Therefore, we take care not to use unique characters such as Turkish characters or spaces in the first rendering, and we update the display name after creating it.
On the SharePoint side, we can back up the list with the data and recreate it in a short time, which of course provides the opportunity up to a certain size. On the SharePoint online side we have an easy powershell script to change this.
For example, I create my list by typing Turkish characters and spaces in the part where I create the first list.
When I name this list like this, it will have a url structure as follows.
This structure will also appear in a different view in some browsers with characters such as ‘%20’.
You can update by typing your site address, list name and new url address using the powershell script below.
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"
$SiteURL= "https://yunusemrearac.sharepoint.com"
$ListName="İlk Listemi Oluşturuyorum"
$NewListURL="Lists/ilklistemiolusturuyorum"
#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
$List=$Ctx.web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
#sharepoint online change library url powershell
$List.Rootfolder.MoveTo($NewListURL)
$Ctx.ExecuteQuery()
#Keep the List name as is
$List.Title=$ListName
$List.Update()
$Ctx.ExecuteQuery()
Write-host -f Green "List URL has been changed!"
}
Catch {
write-host -f Red "Error changing List URL!" $_.Exception.Message
}
Or you can use the following pnp powershell script as an alternative.
#Set Parameters
$SiteURL = "https://yunusemrearac.sharepoint.com/"
$ListName = "İlk Listemi Oluşturuyorum"
$NewListURL = "Lists/ilklistemiolusturuyorum"
#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
$List.Rootfolder.MoveTo($NewListURL)
Invoke-PnPQuery
When we update with these codes, you will see that your list address has changed as follows.
As you can see, I was able to update the url address, that is, the unique name of my list on sharepoint online, simply and quickly.