Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created May 24, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellwest/e19b87e79ca33b941ab1059ea7549e4c to your computer and use it in GitHub Desktop.
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.
$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