Skip to content

Instantly share code, notes, and snippets.

@joshfinley
Created October 2, 2023 20:18
Show Gist options
  • Save joshfinley/106d39a5743610c3b02b421daf8cce53 to your computer and use it in GitHub Desktop.
Save joshfinley/106d39a5743610c3b02b421daf8cce53 to your computer and use it in GitHub Desktop.
# Import the required module if not already imported
Import-Module AzureAD
# Login to Azure AD
Connect-AzureAD
# Get the 'Application Admin' role
$appAdminRole = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Admin'}
# If the role hasn't been instantiated, instantiate it
if ($null -eq $appAdminRole) {
$allRoles = Get-AzureADDirectoryRoleTemplate
$appAdminRoleTemplate = $allRoles | Where-Object {$_.displayName -eq 'Application Admin'}
Enable-AzureADDirectoryRole -RoleTemplateId $appAdminRoleTemplate.ObjectId
$appAdminRole = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Admin'}
}
# Get the members of the 'Application Admin' role
$appAdminMembers = Get-AzureADDirectoryRoleMember -ObjectId $appAdminRole.ObjectId
# Display the members
$appAdminMembers | Select-Object DisplayName, UserPrincipalName, ObjectType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment