BUG: AVD Getting started wizard fails if 'Global Administrator' role group contains an Azure AD App

%3CLINGO-SUB%20id%3D%22lingo-sub-2834359%22%20slang%3D%22en-US%22%3EBUG%3A%20AVD%20Getting%20started%20wizard%20fails%20if%20'Global%20Administrator'%20role%20group%20contains%20an%20Azure%20AD%20App%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2834359%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EBug%3A%3C%2FSTRONG%3E%20Getting%20started%20wizard%20fails%20to%20'validate%20if%20the%20supplied%20AAD%20account%20is%20a%20Global%20Administrator'%20if%20the%20Global%20Administrator%20role%20group%20contains%20an%20Azure%20AD%20App%20(svc%20principal)%20as%20one%20of%20its%20members.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3ERepro%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3EAdd%20an%20Azure%20App%3C%2FLI%3E%3CLI%3EAdd%20the%20App%20to%20GA%20role%20group%3C%2FLI%3E%3CLI%3ERun%20the%20Getting%20started%20Wizard%3C%2FLI%3E%3CLI%3EGSW%20will%20create%20the%20Automation%20account%20with%20Validation%20Runbook%2C%20which%20will%20fail.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EIt%E2%80%99s%20common%20to%20have%20Azure%20AD%20Apps%20(Service%20Principal)%20as%20a%20member%20of%20Global%20Administrators%20Role%20Group.%20We%20need%20help%20in%20making%20the%20getting%20started%20wizard%20continue%20to%20work%20even%20if%20the%20members%20of%20the%20Global%20Administrator%20Role%20group%20are%20non-users.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20happening%20while%20AADDS%20is%20being%20used%20for%20Identity%2C%20but%20may%20happen%20with%20all%20other%20deployment%20types.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20are%20the%20two%20lines%20that%20fails%20in%20Easy-Button%20Deploy%20(%3CEM%3EAzure%20Automation%20Runbook%3C%2FEM%3E%3A(%3C%2Fimg%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24GlobalAdministratorRoleTemplateId%20%3D%20'62e90394-69f5-4237-9190-012177145e10'%0A%24GlobalAdministratorRoleId%20%3D%20Get-AzureADDirectoryRole%20%7C%20Where-Object%20%7B%20%24_.roleTemplateId%20-eq%20%24GlobalAdministratorRoleTemplateId%20%7D%0A%24IsAdminUserGlobalAdministrator%20%3D%20Get-AzureADDirectoryRoleMember%20-ObjectId%20%24GlobalAdministratorRoleId.ObjectId%20%7C%20Get-AzureADUser%20%7C%20Where-Object%20%7B%20%24_.UserPrincipalName%20-eq%20%24context.Account.Id%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EFYI%3A%20Already%20submitted%20to%26nbsp%3B%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Favdgsquestions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2Favdgsquestions%3C%2FA%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EError%20Message%20in%20Easy-Button%20PowerShell%20Runbook%3A%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3E------------------------------------------------------------------------------------------------------------%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3EGet-AzureADUser%20%3A%20Error%20occurred%20while%20executing%20GetUser%20%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3ECode%3A%20Request_ResourceNotFound%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EMessage%3A%20Resource%20%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3E'119ff567-3f2e-4e86-a28f-6449f5ee7644'%3C%2FSTRONG%3E%3C%2FFONT%3E%20does%20not%20exist%20or%20one%20of%20its%20queried%20reference-property%20objects%20are%20not%20present.%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3ERequestId%3A%20b6603f72-cbdd-421a-9884-4db0ad8a159d%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EDateTimeStamp%3A%20Mon%2C%2011%20Oct%202021%2006%3A08%3A20%20GMT%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EHttpStatusCode%3A%20NotFound%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EHttpStatusDescription%3A%20Not%20Found%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EHttpResponseStatus%3A%20Completed%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EAt%20line%3A1%20char%3A114%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%2B%20...%20bjectId%20%24GlobalAdministratorRoleId.ObjectId%20%7C%20Get-AzureADUser%20%7C%20Where%20...%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%2B%20~~~~~~~~~~~~~~~%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%2B%20CategoryInfo%20%3A%20NotSpecified%3A%20(%3A)%20%5BGet-AzureADUser%5D%2C%20ApiException%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.Open.AzureAD16.Client.ApiException%2CMicrosoft.Open.AzureAD16.PowerShell.GetUser%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3E---------------------------------------------------------------------------------------------------------%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3E'119ff567-3f2e-4e86-a28f-6449f5ee7644'%20%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3Ein%20the%20above%20error%20message%20is%20the%20ObjectID%20of%20the%20Azure%20Ad%20App%20which%20is%20returned%20as%20one%20of%20the%20members%20of%20the%20Global%20Administrator%20Role%20Group%20and%20the%20validation%20script%20doesn't%20know%20how%20to%20handle%20that%20parsed%20object%2C%20it%20doesn't%20have%20UPN%2C%20doesn't%20have%20other%20%3CSTRONG%3Ereference-property%3C%2FSTRONG%3E%20that%20would%20User%20object%20have.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2834359%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAVD%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Virtual%20Desktop%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EGetting%20Started%20Wizard%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2837715%22%20slang%3D%22en-US%22%3ERe%3A%20BUG%3A%20AVD%20Getting%20started%20wizard%20fails%20if%20'Global%20Administrator'%20role%20group%20contains%20an%20Azure%20AD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2837715%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F195573%22%20target%3D%22_blank%22%3E%40Stefan%20Georgiev%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EWould%20you%20be%20able%20help%20us%3F%3C%2FLINGO-BODY%3E
New Contributor

Bug: Getting started wizard fails to 'validate if the supplied AAD account is a Global Administrator' if the Global Administrator role group contains an Azure AD App (svc principal) as one of its members.

Repro:

  • Add an Azure App
  • Add the App to GA role group
  • Run the Getting started Wizard
  • GSW will create the Automation account with Validation Runbook, which will fail.

It’s common to have Azure AD Apps (Service Principal) as a member of Global Administrators Role Group. We need help in making the getting started wizard continue to work even if the members of the Global Administrator Role group are non-users.

 

This is happening while AADDS is being used for Identity, but may happen with all other deployment types.

 

Below are the two lines that fails in Easy-Button Deploy (Azure Automation Runbook:(

 

$GlobalAdministratorRoleTemplateId = '62e90394-69f5-4237-9190-012177145e10'
$GlobalAdministratorRoleId = Get-AzureADDirectoryRole | Where-Object { $_.roleTemplateId -eq $GlobalAdministratorRoleTemplateId }
$IsAdminUserGlobalAdministrator = Get-AzureADDirectoryRoleMember -ObjectId $GlobalAdministratorRoleId.ObjectId | Get-AzureADUser | Where-Object { $_.UserPrincipalName -eq $context.Account.Id }

 

FYI: Already submitted to https://aka.ms/avdgsquestions

 

Error Message in Easy-Button PowerShell Runbook:

------------------------------------------------------------------------------------------------------------

Get-AzureADUser : Error occurred while executing GetUser
Code: Request_ResourceNotFound
Message: Resource '119ff567-3f2e-4e86-a28f-6449f5ee7644' does not exist or one of its queried reference-property objects are not present.
RequestId: b6603f72-cbdd-421a-9884-4db0ad8a159d
DateTimeStamp: Mon, 11 Oct 2021 06:08:20 GMT
HttpStatusCode: NotFound
HttpStatusDescription: Not Found
HttpResponseStatus: Completed
At line:1 char:114
+ ... bjectId $GlobalAdministratorRoleId.ObjectId | Get-AzureADUser | Where ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureADUser], ApiException
+ FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetUser

---------------------------------------------------------------------------------------------------------

'119ff567-3f2e-4e86-a28f-6449f5ee7644' in the above error message is the ObjectID of the Azure Ad App which is returned as one of the members of the Global Administrator Role Group and the validation script doesn't know how to handle that parsed object, it doesn't have UPN, doesn't have other reference-property that a User object would have.

1 Reply