【问题标题】:SharePoint Content Editor Web Part InventorySharePoint 内容编辑器 Web 部件清单
【发布时间】:2019-07-14 17:05:47
【问题描述】:

我有一个为 SharePoint 2010 编写的 PowerShell 脚本的问题,它仅在一个网站集 http://company/ 上工作,它使用带有图像映射的内容编辑器 Web 部件列出所有页面,一旦循环转到下一个网站集它什么也不返回。

当脚本循环遍历所有其他网站集时,它不会向 $publishingPages 返回任何内容 - 我可以看到 $publishingWeb 正确加载并返回其数据,但我什么也没得到:

$publishingWeb.GetPublishingPages($publishingWeb)

我使用不同的 SharePoint 帐户(设置、农场、管理员等)运行脚本,结果始终相同,我不知道我在这里可能做错了什么!

这是我的代码:

Start-SPAssignment -Global

$SPWebApp = Get-SPWebApplication "http://company/" 

foreach ($site in $sites)
{
    foreach ($web in $site.AllWebs)
    {
        Write-Host `n "-" $web.Url `n  -ForegroundColor Green

        if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))
        {
            $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
            $publishingPages = $publishingWeb.GetPublishingPages($publishingWeb)

            foreach($page in $publishingPages)
            {  
                $manager = $web.GetLimitedWebPartManager($page.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

                $allWebParts = $manager.WebParts
                $onlyCEWP = $allWebParts | ? {$_.GetType() -eq [Microsoft.SharePoint.WebPartPages.ContentEditorWebPart]}
                $imageMaps = $onlyCEWP | ? {$_.Content.InnerText -match '<map name='}

                if ($imageMaps -ne $null)
                {
                    Write-Host `t " - " $page.Url
                }
            }
        }

        $web.Dispose()
    }

    $site.Dispose()
}


Stop-SPAssignment -Global

【问题讨论】:

    标签: powershell sharepoint sharepoint-2010


    【解决方案1】:

    上面的脚本没有任何问题,原来我们的客户已经将所有页面放在页面库之外,因此一旦库为空,脚本就会查找页面:)

    【讨论】:

      猜你喜欢
      • 2016-10-21
      • 2012-09-15
      • 2017-11-29
      • 2012-11-08
      • 2012-03-13
      • 2017-04-12
      • 2011-09-24
      • 2019-09-11
      • 2016-11-18
      相关资源
      最近更新 更多