Collecting Role Membership Criteria / PowerShell 7 / Role Importer

TylerT,

Here is a script I wrote to print out all the values from the criteria from a Role. You should be able to modify this in order to get what you need for the Role Importer.

function Get-Criteria {
    param (
        [PSObject[]]$child
    )
    
    $child.operation
    "   " + $child.key.type
    "   " + $child.key.property
    "   " + $child.key.sourceId
    $child.stringValue

    "----"

    if ($null -ne $child.children) {
        foreach($child in $child.children) {
            Get-Criteria $child
        }
    }
}

$roleInfo = Get-Content Role.json | ConvertFrom-Json

foreach ($info in $roleInfo.PSObject.Properties) {
    if ($info.name -eq "membership") {
        foreach($child in $info.value.criteria.children) {
            Get-Criteria $child
        }
    }
}