Created
May 24, 2020 14:28
-
-
Save michaellwest/e19b87e79ca33b941ab1059ea7549e4c to your computer and use it in GitHub Desktop.
Find home items where a rendering has 1 or more rules applied using Sitecore PowerShell Extensions.
This file contains 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
$device = Get-LayoutDevice -Default | |
$sites = [Sitecore.Configuration.Factory]::GetSiteInfoList() | |
foreach($site in $sites) { | |
$isTrackingEnabled = [Sitecore.MainUtil]::GetBool($site.Properties["enableTracking"], $true) | |
if($isTrackingEnabled -or [string]::IsNullOrEmpty($site.TargetHostName)) { continue } | |
$homeItem = Get-Item -Path "$($site.RootPath)/$($site.StartItem)".Replace("/sitecore", "master:") | |
Write-Host "Checking $($homeItem.ItemPath)" | |
foreach($rendering in $homeItem.Visualization.GetRenderings($device, $false)) { | |
if($rendering.Settings.Rules.Count -le 0) { continue } | |
$rendering | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment