Created
September 23, 2022 03:24
-
-
Save michaellwest/a2a0189b11d62d64ea76b777c48145b8 to your computer and use it in GitHub Desktop.
Sitecore PowerShell Extensions report to find all script and script library items containing either a ShowRule or EnableRule.
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
<# | |
.SYNOPSIS | |
Report all the PowerShell Script (Library) items which contain a ShowRule or EnableRule | |
.NOTES | |
Michael West | |
#> | |
$items = Get-ChildItem -Path "master:" -ID "{A3572733-5062-43E9-A447-54698BC1C637}" -Recurse | Where-Object { ($_.ShowRule -and $_.ShowRule -ne "<ruleset />") -or ($_.EnableRule -and $_.EnableRule -ne "<ruleset />") } | |
function Render-Rule { | |
param( | |
[string]$rule | |
) | |
$output = New-Object System.Web.UI.HtmlTextWriter (New-Object System.IO.StringWriter) | |
$renderer = New-Object Sitecore.Shell.Applications.Rules.RulesRenderer ($rule) | |
$renderer.Render($output) | |
$output.InnerWriter.ToString() | |
} | |
$items | Show-ListView -Property Name, ItemPath, @{Name="ShowRule";Expression={Render-Rule -Rule $_.ShowRule}}, @{Name="EnableRule";Expression={Render-Rule -Rule $_.EnableRule}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment