[英]SharePoint Content Editor Web Part Inventory
我有一個為 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
上面的腳本沒有任何問題,結果我們的客戶將所有頁面都放在了 Pages 庫之外,因此一旦庫為空,腳本就會查找頁面:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.