开发者

Update SharePoint quicklaunch link URL through PowerShell

开发者 https://www.devze.com 2023-01-26 17:14 出处:网络
The setup is MOSS2007. I iterate the links in the QuickLaunch, and update the URL: $siteUrl = \"http://myserver/\"

The setup is MOSS2007. I iterate the links in the QuickLaunch, and update the URL:

$siteUrl = "http://myserver/"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl) 
for($i=0; $i -lt $spSite.AllWebs.Count;$i++)
{
    $spWeb = $spSite.AllWebs[$i]
    $nodes = $spWeb.Navigation.QuickLaunch
    for($j=0; $j -lt $nodes.Count;$j++)
    {
            $children = $nodes[$j].Children
            for($k=0; $k -lt $children.Count;$k++)
            {
                    $x = $children[$k]
                    $x.Url = "http://mylink/"
                    $x.Update()
            }
    }
    $spSite.Dispose();
}

But the Doclib URLs don't update. If I go to Site settings -> Navigation -> and edit the URL through the UI, then run my script again, the URL updates. Why can't I manipulate th开发者_JAVA百科e URL through code?


I'm not sure if this is the answer, but it looks to me like your Dispose is in the wrong place. It should be outside the outer foreach, i.e. at the same nesting level as your $spSite assignment. This repeated dispose may be causing sync problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消