Public/Get-IAMCoreOrgUnit.ps1

<#
.SYNOPSIS
    Gets CoreOrgUnit objects from the IAM Core API.

.DESCRIPTION
    This function retrieves CoreOrgUnit objects from the IAM Core API.

.EXAMPLE
    Get-IAMCoreOrgUnit
#>

function Get-IAMCoreOrgUnit {
    [CmdletBinding(DefaultParameterSetName = "Default")]
    param (
        [Parameter(Mandatory = $false, ParameterSetName = "Default")]
        [int] $PageSize = 10000,

        [Parameter(Mandatory = $true, ParameterSetName = "Single", ValueFromPipelineByPropertyName = $true)]
        [ValidatePattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", ErrorMessage = "Id must be a valid GUID.")] # Is a guid connector object id
        [string] $Id
    )

    process {
        if ($PSCmdlet.ParameterSetName -eq "Single") {
            Get-IAMCoreObject -ObjectType "CoreOrgUnit" -Id $Id
        }
        else {
            Get-IAMCoreObject -ObjectType "CoreOrgUnit" -PageSize $PageSize
        }
    }
    
}