【发布时间】: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