public/Get-RBACGlobal.ps1

function Get-RBACGlobal {
    [CmdletBinding(DefaultParameterSetName='None')]
    Param
    (

        # Don't search AD-- mock what you would get.
        [Parameter(ParameterSetName="Mock",Mandatory)]
        [switch]$Mock,

        [Parameter(ParameterSetName="Mock",ValueFromPipelineByPropertyName, ValueFromPipeline)]
        [String]$Description="Mock Description",

        [switch]
        $Detailed,

        [Microsoft.ActiveDirectory.Management.ADDirectoryServer]$Server = (get-addomainController -Writable -Discover)
    )

    Begin {
        $SearchParams = @{
            SearchScope = "OneLevel"
            Properties = "Description"
        }
    }

    PROCESS {
        try {
            $GlobalRoot = if ([bool]$mock) {
                [pscustomObject]@{
                    Name = $(split-ldapPath -distinguishedName $settings['OUPaths']['Global'] -leaf -NodeNameOnly)
                    Description = $Description
                    DistinguishedName = $settings['OUPaths']['Global']
                }
            } else {
                Get-ADOrganizationalUnit -Identity $Settings['OUPaths']['Global'] -properties Description
            }
            $BaseDN = $GlobalRoot.DistinguishedName
            $Children = $(
                if ([bool]$mock) {
                    $GlobalTemplate['LDAPContainers']
                } else {
                    get-adorganizationalUnit -searchBase $BaseDN @SearchParams -filter "*" | foreach-object {
                        @{
                            DistinguishedName = $_.distinguishedName
                            Description = $_.description
                        }
                    }
                }
            ) | foreach-object {[pscustomobject]$_ } | resolve-rbacchildren -baseDN $baseDN

                [PSCustomObject]@{
                    Name = $Settings['Names']['GlobalOU']
                    Type = "Global"
                    Org = ""
                    Component = ""
                    Description = $ADObject.Description
                    DistinguishedName = $Settings['OUPaths']['Global']
                    Path = split-ldappath -DistinguishedName $Settings['OUPaths']['Global'] -Parent
                    ObjectMidName = $Settings['Names']['GlobalOU']
                    Children = $Children
                    Parents = [hashtable]::new()
                }
            } catch {
                throw $_
            }
    }
}