I am trying to edit a top navigation bar Heading's description so at the top ribbon I would have a its description at mouse hover. I am going to have to do it with powershell, as a script, because it is to be deployed and i wont be able to edit it one by one.

function ProcessSubWebs($webAppUrl)
    $currentWeb = Get-SPWeb $webAppUrl
    $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($currentWeb)
    $publishingPages = $publishingWeb.GetPublishingPages()
    foreach ($publishingPage in $publishingPages)
        if($publishingPage.ListItem['Title'] -eq "<Page Name>")
            $file = $currentWeb.GetFile($publishingPage.Uri.ToString())  
            [Microsoft.SharePoint.SPListItem]$spListItem = $file.Item 
            $spListItem.Description = "<Page Description>"
            $file.CheckIn("Description Added", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)          

$webAppUrl = "MyUrl"

Apparently I cannot change description of a list item with $listItem.Description or $listItem['Description']

I also have tried to do it as a publishingPage but it did not work after update. I'd be glad if you could point me to the right direction.


Ok, I have solved my issue with ISE, debugged it and found out that, first, i was going through the wrong list and that i was supposed to go through the $rootSiteCollection.RootWeb.Navigation.TopNavigationBar and that the property i was looking for was to be accessed by using $node.Properties["Description"].

I have changed more or less the whole thing., for people who may need it here is the whole script to change an items description on the top navigation bar.

$siteCollectionUrl = "http://MySPsite/sites/siteX"
    $rootSiteCollection = Get-SPSite $siteCollectionUrl
    if ($rootSiteCollection -ne $null)
        $rootWeb = $rootSiteCollection.RootWeb
        $navigationNodes = $rootWeb.Navigation.TopNavigationBar
        if ($navigationNodes -ne $null)
            foreach($navNode in $navigationNodes)

                if($navNode.Title -eq "<Button To Change>" -and $navNode.Properties["NodeType"] -eq "Heading") 
                # instead of Heading, Link or Subsite can also be used if that is the case
                    $navNode.Properties["Description"] = "<New Description>"

            $rootWeb.AllowUnsafeUpdates = 1
            $rootWeb.AllowUnsafeUpdates = 0
            $rootSiteCollection.AllowUnsafeUpdates = 1
            $rootSiteCollection.AllowUnsafeUpdates = 0

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.