1

I am trying to update the value using:

$lista.Views[0].Title="New Title"
$lista.Views[0].Title.Update()

and

$lista.Views[0].TitleResource.Value="New Title"
$lista.Views[0].TitleResource.SetValueForUICulture("en-US","New Title")
$lista.Views[0].TitleResource.Update()

I end up with the following: enter image description here

and the title in the UI does not change.

I set the environment's culture to the culture of the web as per this article but it seemed to have no effect.
I tried setting an xml with updated displayname :

$lista.Views[0].SetViewXml($xeml)
$lista.Update()

but again to no effect (no errors as well).

Updating via user interface works without any issues.

EDIT

enter image description here

1

Yes, this is one of my favorites. It's SharePoint's punishment for lazy programming ;)

Try this code:

$list.Views[0] -eq $list.Views[0]

This results in False. That's because $list.Views[0] always returns new instance. Same as $web.Lists['Title'] and few more examples.

Solution:

$view = $list.Views[0]
$view.Title = 'New Title'
$view.Update()
  • I wish it was that, but it's not :( I think it has something to do with the alternate languages installed. The value "Deutsches Titel2" (see edit) is not present as any of the properties of the view. It is not a displayname, title or titleresource. – grisha Jul 28 '16 at 7:59
0

dstarkowski is right. Please try:

function ChangeViewTitle
{
    [CmdletBinding()]            
    Param(              
        [parameter(Mandatory=$true)][string]$listName,
        [parameter(Mandatory=$true)][string]$viewName,
        [parameter(Mandatory=$true)][string]$newTitle

    $view=$web.Lists[$listName].Views[$viewName]
    if($view -ne $null)
    {
        [System.Threading.Thread]::CurrentThread.CurrentUICulture
        [int]$lcid = $web.Language
        $culture = new-object "System.Globalization.CultureInfo" $lcid
        ForEach($culture in $web.SupportedUICultures)
        {
          [System.Threading.Thread]::CurrentThread.CurrentUICulture=$culture
          [System.Threading.Thread]::CurrentThread.CurrentUICulture

          $view.Title=$newTitle
          $view.Update()

        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.