src/Private/aad.ps1



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

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

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