1

We are trying to get report using Powershell to list all sub items under one item and some of it's fields. One field in the item is of Rules field type. We are able to fetch RuleSet XML (<rulesetCustom Rules>) from the field. However we need it in readable format as shown in Content Editor.

Is there any way to fetch it using Powershell?

Thanks, PC

1
  • Feel free to accept the answer by choosing the checkmark. Commented May 5, 2021 at 14:35

1 Answer 1

5

I managed to get it working using this approach:

$item = Get-Item -Path "master:{F4819743-C9D5-48A4-911B-017F8BA1415C}"
# Change the name 'ShowRule' to whatever your rule field is called
$renderer = New-Object Sitecore.Shell.Applications.Rules.RulesRenderer ($item.ShowRule)

$sw = New-Object System.IO.StringWriter
$renderer.Render($sw)

$records = @()
$records += [PSCustomObject]@{
    "RuleHtml" = $sw.ToString()
}

$records | Show-ListView

enter image description here

1
  • Hi Michael, This works perfect. Thanks for saving my day.
    – user8239
    Commented May 4, 2021 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.