0

我在尝试使用 powershell 在 sharepoint 2013 站点上快速启动时更新链接 url 时遇到问题。基本上我只想更改特定链接的 url。我的 Powershell 脚本代码如下:

function FixUrlDocumentsLists() {
param([Microsoft.SharePoint.SPWeb]$SiteIdentity)

if ($SiteIdentity.Url -Like "http://mktintranet/sites/tmmkto/ITReports")
{
    $quicklaunch = $SiteIdentity.Navigation.QuickLaunch

    if($quicklaunch.Count -gt 0)
    {
        foreach($node in $quicklaunch)
        {
            if ($node.Title.ToUpper() -ne "HOME" -and $node.Title.ToUpper() -ne "SITE CONTENTS")
            {
                if($node.Url -eq $SiteIdentity.ServerRelativeUrl)
                {
                    Write-Host "Fixing navigation links for web $($SiteIdentity.Title)" -ForegroundColor Yellow
                    Write-Host "Link Title: $($node.Title), OLD Link Url: $($node.Url)" -ForegroundColor Yellow

                    $node.Url=$node.Url.ToString()+"/_layouts/15/viewlsts.aspx"


                    Write-Host "Link Title: $($node.Title), NEW Link Url: $($node.Url)" -ForegroundColor Yellow

                    $node.Update()
                    $SiteIdentity.Update()
                }

            }

        }

    }
}


if($SiteIdentity.Webs.Count -gt 0)
{
    foreach($subWeb in $SiteIdentity.Webs)
    {
        FixUrlDocumentsLists -SiteIdentity $subWeb
    }
}

}

错误发生在 $node.Update() 方法上。错误描述如下:

Exception calling "Update" with "0" argument(s): "Cannot open "/sites/tmmkto/ITReports/_layouts/15/viewlsts.aspx": no such file or folder."

我不明白为什么 Update 方法会进行 Url 验证。即使路径 /sites/tmmkto/ITReports/_layouts/15/viewlsts.aspx 确实存在。

谢谢,

马丁

4

2 回答 2

1

如果它是内部 url,SharePoint 会尝试验证节点 url。解决这个问题的方法是将您的链接标记为外部(即使不是):Node.IsExternal = true; (csom)

于 2017-08-15T17:28:14.667 回答
-1

请确保未选中显示子站点/显示页面选项

站点设置 => 导航 => 当前导航 =>

在导航中:仅显示当前站点下方的导航项。如果您尝试更新从子站点/页面文件生成的导航链接,您将收到此类错误。如果启用此选项并且您尝试修改自动生成的子站点/页面链接的链接,则给出错误是有意义的。

于 2016-08-15T14:22:11.633 回答