Private/aad.ps1

function Get-RKAADServicePrincipalObjectId {
    [CmdletBinding()]
    param([string]$ApplicationName)
    $ApplicationId = (Get-AzADApplication -DisplayName $ApplicationName).ApplicationId
    if (!($ApplicationId)) {
        Write-Error "Application $ApplicationName not found"
    }
    return (Get-AzADServicePrincipal -ApplicationId $ApplicationId).Id
}

function Get-RKAADGroupObjectId {
    [CmdletBinding()]
    param([string]$GroupName)
    $Id = (Get-AzAdGroup -DisplayName $GroupName).Id
    if (!($Id)) {
        Write-Error "AAD Group $GroupName not found"
    }
    return $Id
}

function Get-RKAADUserObjectId {
    [CmdletBinding()]
    param([string]$UserName)
    $Id = (Get-AzAdUser -UserPrincipalName $UserName).Id
    if (!($Id)) {
        Write-Error "AAD User $UserName not found"
    }
    return $Id
}