Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Wednesday, May 2, 2018

How to rename a SharePoint List URL

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

So here’s where PowerShell comes into play.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.

Hope this help!

How to export a schema.xml file for a list from a SharePoint site

How to export a schema.xml file for a list from a SharePoint site In sharepoint, we can retrieve the XML schema of any list by using ...