Created
October 2, 2023 20:18
-
-
Save joshfinley/106d39a5743610c3b02b421daf8cce53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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