SharePoint 内容编辑器 Web 部件清单



我在使用 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

上面的脚本没有任何问题,事实证明我们的客户将所有页面都放在了页面库之外,因此一旦库为空,脚本就会查找页面:)

最新更新