2015-05-04 69 views
0

我試圖更新使用PowerShell在我的SharePoint網站上的結題並不反映:如果我嘗試第二次更新兒童使用PowerShell節點在SharePoint GUI

$web = Get-SPWeb "http://dev:18792/sites/devsite/" 

foreach ($webs in $web.Webs) 
{ 

$nodes = $webs.Navigation.QuickLaunch 
foreach ($node in $nodes) 
{ 
    $nodeTitle = $node.Title 
    if ($nodeTitle.ToString().Contains("First node")) 
    { 
     foreach ($nodeChild in $node.Children) { 

      $nodeChildTitle = $nodeChild.Title 

      if ($nodeChildTitle.ToString().Contains("Original childnode title")) { 

       $nodeChild.Title = "Changed title" 
       $nodeChild.Update() 
       Write-Host "done." 
      } 
     } 

    } 
    $webs.Dispose() 
} 
$web.Dispose() 
} 

,改變

.Contains("Original childnode title") 

到:

.Contains("Changed title") 

它輸入if語句,但變化並不在GUI中可見。

我在這裏錯過了什麼嗎?

回答

0

難道這可能是因爲您的發佈功能已激活?在發佈網站上操作快速啓動有點不同。下面是一些示例C#代碼:

PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(oWeb); 
SPNavigationNodeCollection nodes = pubWeb.Navigation.CurrentNavigationNodes; 
foreach (SPNavigationNode node in nodes) 
{ 
    if (node.Title == "Original Title") 
    { 
     node.Title = "New Title"; 
     node.Update(); 
     break; 
    } 

}

否則嘗試調用$ webs.Update()方法