Home Gitesh Portfolio Blog About Me Gallery Contact

Sitecore: Powershell query to create a Sitemap from Sitetree

With this powershell command you will be to create a Sitemap from Sitetree.

 


<#
  Sitemap for Sitetree. Goes through all child items and creates a child map
#>

$item = Get-Item -Path "master:\content\IR\Home\Home"

$items = @()
Get-Item -Path master: -ID $item.ID -Language * | ForEach-Object { $items += @($_) + @(($_.Axes.GetDescendants())) | Where-Object { $_.TemplateName -ne "Page Data"} | Initialize-Item }
$ritems = @()
$items | ForEach-Object {
    $ritems += Get-Item -Path master: -ID $_.ID 
}
$reportProps = @{
	Property = @(
		"DisplayName",
		@{Name="Path"; Expression={$_.ItemPath}},
		@{Name="Template"; Expression={$_.TemplateName}},
		#@{Name="Renderings"; Expression={$_.__Renderings}},
		@{Name="Last Updated"; Expression={$_.__Updated}}
	)
	Title = "Sitemap for Sitetree"
	InfoTitle = "Goes through all child items and creates a child map"
	InfoDescription = "Sitemap generation."
}
$ritems | Show-ListView @reportProps

Close-Window


Posted: 12/12/2022 1:38:22 a.m. by Gitesh Shah | with 0 comments