if ($ver.Version.Major - gt 1) {
$Host.Runspace.ThreadOptions = "ReuseThread"
}
Add - PsSnapin Microsoft.SharePoint.PowerShell - ErrorAction SilentlyContinue
Set - location $home
$str = "http://localhost"
function ProcessSubWebs($str) {
$currentWeb = Get - SPWeb $str
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($currentWeb)) {
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($currentWeb)
$publishingPages = $publishingWeb.GetPublishingPages()
foreach($publishingPage in $publishingPages) {
if ($publishingPage.ListItem['Title'] - ne $null) {
select Uri, Title, @ {
Name = ’PageLayout’;
Expression = {
$_.Layout.ServerRelativeUrl
}
}
$publishingPage | select Uri, Title, @ {
Name = ’PageLayout’;
Expression = {
$_.Layout.ServerRelativeUrl
}
}
$SPvaluesforOutput = $publishingPage | Select Uri, Title, Name
$SPvaluesforOutput | Out - File c: \123. csv - append
$publishingPage | Out - File c: \test.csv - append
}
}
foreach($sub in $currentWeb.Webs) {
if ($sub.Webs.Count - gt 0) {
ProcessSubWebs($sub.Url)
}
}
Write - Host - ForegroundColor red "FINISHED"
} else {
Write - Host - Foregroundcolor Red "$str not a publishing site"
}
}
ProcessSubWebs($str)This code snippet for PowerShell to get all publishing page properties from a site.