public/Get-RBACOrg.ps1

function Get-RBACOrg {
    Param
    (
        [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$True, Position=0)]
        [ArgumentCompleter( {(get-rbacOrg).Org})]
        $Org,

        [switch]$Detailed,
        [Switch]$IncludeGlobal

    )

    Begin {
        $SearchParams = @{
            SearchBase = "OU=$($OrgsOUStruct.Name),$($OrgsOUStruct.Path)"
            SearchScope = "OneLevel"
            Properties = "Description"
        }
    }
   
    PROCESS {
        if ($org) 
        {
            $filter = @{ filter = "name -eq '$org'" }
        } Else {
            $filter = @{ filter = "*" }
        }

        $OUList = get-adorganizationalUnit @SearchParams @Filter | foreach-object {
            $thisOrg = [PSCustomObject]@{
                Name = $_.name
                Type = "Org"
                Org = $_.name
                Component = ""
                Description = $_.Description
                DistinguishedName = $_.distinguishedName
                ObjectMidName = "{0}" -f $_.name
            }
            if ($_.name -ne $GlobalOUStruct.name) {
                $ThisOrg
            } elseif ([Bool]$IncludeGlobal) {
                $thisOrg.Type = "Global"
                $ThisOrg
            } else {
                Write-Verbose "Skipping global Org, IncludeGlobal not specified"
            }
        }
        if (-not [bool]$Detailed) {
            $OUList | select-object Org,Description,DistinguishedName
        } else {
            $OUList
        }
        
    }
}