Created
July 20, 2023 12:00
-
-
Save agehlot/f89d322e6ab28ee95993f9f5653890ca to your computer and use it in GitHub Desktop.
Get page wise component list from Sitecore tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This script will Find all components / renderings added on an item in Sitetree. | |
Goes through all child items and finds the renderings for that item | |
#> | |
$allRendering = Get-ChildItem -Path "master:\layout\Renderings" -Recurse | | |
Where-Object { $_.TemplateName -like "*rendering*" } | | |
Select-Object Name, ID, TemplateName | | |
Sort-Object -Property Name | |
$rootPath = 'master:/sitecore/content/NOV Com/Home' | |
$itemsToProcess = Get-ChildItem -Path $rootPath -Recurse | |
$list = @() | |
foreach ($item in $itemsToProcess) { | |
$itemRenderings = Get-Rendering -Item $item -FinalLayout #| Where-Object { $_.Cachable -ne "1" } | |
foreach ($itemRendering in $itemRenderings) { | |
$renderingItem = $allRendering | Where-Object { $_.ID -eq $itemRendering.ItemID } | |
if ($renderingItem -ne $null) { | |
$itemRendering = [PSCustomObject]@{ | |
ItemPath = $item.Paths.FullPath | |
RenderingName = $renderingItem.Name | |
RenderingId = $renderingItem.ID | |
} | |
$list += $itemRendering | |
} | |
} | |
} | |
$reportProps = @{ | |
Property = @( | |
@{Name="ItemPath"; Expression={$_.ItemPath}}, | |
@{Name="RenderingName"; Expression={$_.RenderingName}}, | |
@{Name="RenderingId"; Expression={$_.RenderingId}} | |
) | |
Title = "Find all components / renderings added on an item in Sitetree" | |
InfoTitle = "Goes through all child items and finds the renderings for that item" | |
InfoDescription = "Find all renderings." | |
} | |
$list | Show-ListView @reportProps | |
Close-Window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment