Use PowerShell to update a Web Title

At the SharePoint Saturday last week I got a question about renaming and moving a site with PowerShell. Someone wanted to move their existing site to a new URL and rename it with a new Site Title, so he ported some c# example on the internet to a PowerShell script but it did not update the title property as expected, so I had a quick look at it.

The thing with renaming the title from PowerShell (or any code for that matter) has some issues when you have another language selected for the created web than English. What happens is that the web.title property that you need to update supports multilingual sites, and thus can have different values for different available languages.So if you would read blog posts about changing the title and description the code would be pretty straight forward:

$web = Get-SPWeb "http://someurl";
$web.ServerRelativeUrl = "/newteamsiteurl";
$web.Title = "New Title"; 
$web.Update();

But as stated that will not work for any web that is created with a different language than English. Since this is an 'issue' that is out there for a quite a while, there are some 'older' posts out there like Updating Site Title programmatically that suggest you update all SPUserResources. Now that will be something that can come in handy if you would have a lot of different languages available on your farm, yet there is a slightly more elegant way of doing it.

$web = Get-SPWeb "http://someurl";
$web.ServerRelativeUrl = "/newteamsiteurl";
$web.TitleResource.SetValueForUICulture($web.UICulture, "New title");
$web.Update();

That way you can update the title for the Culture the web is created in (wether it is Dutch or some of the other available translations of SharePoint, without having to write code to loop through all UICultures, and thus update the title of the web pretty quick.

Leave a Reply