Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to edit an item in the TopNavigationBar with a PowerShell script. I´m using a Windows Server 2008 R2 (English) with SharePoint 2013 (German).

My PowerShell script says that the Title is changed. But at the UI is still the old name "OldName". When I´m doing a double check with PowerShell, I can see the Title changed to "NewName"

Is there a UI Culture property? How can I change the Title?

Thanks in advance!

$Web = Get-SPWeb "https://sharepoint.url"
$tempname = "NewName"

$TopNavigationBar = $Web.Navigation.TopNavigationBar
foreach($NavItem in $TopNavigationBar)
{
    if($NavItem.Title -eq "OldName")
    {
    Write-Host "Change Navigation" -ForegroundColor Green
    $NavItem.Title = $tempname

    $NavItem.Update()
    $TestWeb.Update()
    }
}
$Web.dispose()

#Check
$WebCheck = Get-SPWeb "https://sharepoint.url"
$WebCheck.Navigation.TopNavigationBar
$WebCheck.dispose()
share|improve this question

1 Answer 1

how about

$Web = Get-SPWeb "https://sharepoint.url"
$tempname = "NewName"

$TopNavigationBar = $Web.Navigation.TopNavigationBar
foreach($NavItem in $TopNavigationBar)
{
    if($NavItem.Title -eq "OldName")
    {
    Write-Host "Change Navigation" -ForegroundColor Green
    $NavItem.Title = $tempname

    $NavItem.Update()
    $web.AllowUnsafeUpdates = $true
    $Web.Update()
    $web.AllowUnsafeUpdates = $false
    }
}
$Web.dispose()

#Check

$WebCheck = Get-SPWeb "https://sharepoint.url"
$WebCheck.Navigation.TopNavigationBar
$WebCheck.dispose()

you need to do it same way as you do it though c# , AllowUnsafeUpdates to force changes on a list when you are trying to update the database as a result of the GET request.

equally important is updating the web object and not $TestWeb.Update() :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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