Public/aad.ps1

function Get-RKAADObjectId {
    <#
    .Description
    Return the objectId for item.
    For User it expects the UPN (email address)
    For Application it will return the associated Service Principal objectId
    #>

    [CmdletBinding()]
    param(
        [parameter(Mandatory = $false)][ValidateSet("Group", "User", "MSI", "Application")][string]$ObjectType = "User",
        [parameter(ValueFromPipeline, Mandatory = $true)][string]$DisplayName
    )
    $objectId = switch ($ObjectType) {
        "Group" { Get-RKAADGroupObjectId $DisplayName }
        "Application" { Get-RKAADServicePrincipalObjectId $DisplayName }
        "User" { Get-RKAADUserObjectId $DisplayName }
        #MSI requires full resource id e.g. (/subscriptions/xxx/resourceGroups/xxx...)
        "MSI" { Get-RKResourceMSI $DisplayName }
    }
    return $objectId
}