PowerShell – How to rename a SharePoint List URL

Sometime you created a list and afterwards change your mind about the name of the list.

You can easily change the list Title and Description. But is does not change the URL accordingly Sad smile

image

So here’s where PowerShell comes into play.

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$web = Get-SPWeb "http://YourWeb/sites/"

$list = $web.Lists["OLD Name"]

# Display the fields, so to make sure you are grabbing the correct list in the correct site collection
$list.Fields | sort StaticName,Type | ?{$_.CanBeDeleted -eq $true -and ´
              $_.Hidden -eq $false} | FT Title,StaticName,Type

# Check the name name and destination before
# $list.RootFolder

$list.RootFolder.Name
$list.RootFolder.Url

$web.Lists["OLD Name"].RootFolder.MoveTo("/Lists/NEW Name")

# Check the name name and destination afterwards
$list.RootFolder.Name
$list.RootFolder.Url

As you can see it is using the MOVETO method to rename the list.

TIP :

Notice the new name path

It has the “/LISTS/” path in front ! this is importain to locate the new list in the same position as that other native SharePoint lists.

Of course if you don’t like to play with PS then you can still use SP Designer to do the job.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: