Powershell将列出所有页面及其遍布rootweb和所有子站点的布局?

时间:2013-09-04 05:52:52

标签: sharepoint powershell

我需要能够创建所有现有页面及其页面布局的报告。 我有以下powershell脚本,但即使使用Recursive,它只返回来自根网站的那些。

filter Get-PublishingPages { 
    $pubweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($_)
    $query = new-object Microsoft.SharePoint.SPQuery 
    $query.ViewAttributes = "Scope='Recursive'"
    $pubweb.GetPublishingPages($query)    
} 
$url="https://xxxxl.com"
get-spweb $url | Get-PublishingPages | select Uri, Title, @{Name='PageLayout';Expression={$_.Layout.ServerRelativeUrl}}

2 个答案:

答案 0 :(得分:3)

这对我有用。

filter Get-PublishingPages {
$pubweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($_)
$query = new-object Microsoft.SharePoint.SPQuery

$query.ViewAttributes = "Scope='Recursive'"
$pubweb.GetPublishingPages($query)
}

$str = "http://yourdomain.com" // your URL
if($str -eq $null )
{
Write-Host “Enter a valid URL”
return
}

$site = Get-SPSite -Identity $str
if($site -eq $null)
{
Write-Host “Enter a valid URL”
return
}

$allweb = $site.Allwebs
foreach($web in $allweb )
{
$web | Get-PublishingPages | select Uri, Title, @{Name=’PageLayout’;Expression={$_.Layout.ServerRelativeUrl}}| Format-List
}

答案 1 :(得分:0)

这里有一个黑暗的镜头,但是你尝试将范围设置为RecursiveAll而不仅仅是Recursive吗?我的理解是Recursive只能访问文件夹中的所有文件,而RecursiveAll也会获取所有子文件夹。

参考:http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spviewscope.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1