@@ -320,8 +320,14 @@ try {
320320 # Make sure the provisioner OID is set so we can pass it through to the deployment.
321321 if (! $ProvisionerApplicationId -and ! $ProvisionerApplicationOid ) {
322322 if ($context.Account.Type -eq ' User' ) {
323- # Use -Mail as the lookup works in both corp and TME tenants
323+ # Support corp tenant and TME tenant user id lookups
324324 $user = Get-AzADUser - Mail $context.Account.Id
325+ if ($user -eq $null -or ! $user.Id ) {
326+ $user = Get-AzADUser - UserPrincipalName $context.Account.Id
327+ }
328+ if ($user -eq $null -or ! $user.Id ) {
329+ throw " Failed to find entra object ID for the current user"
330+ }
325331 $ProvisionerApplicationOid = $user.Id
326332 } elseif ($context.Account.Type -eq ' ServicePrincipal' ) {
327333 $sp = Get-AzADServicePrincipal - ApplicationId $context.Account.Id
@@ -391,8 +397,14 @@ try {
391397 Write-Warning " The specified TestApplicationId '$TestApplicationId ' will be ignored when -ServicePrincipalAutth is not set."
392398 }
393399
394- # Use -Mail as the lookup works in both corp and TME tenants
400+ # Support corp tenant and TME tenant user id lookups
395401 $userAccount = (Get-AzADUser - Mail (Get-AzContext ).Account.Id)
402+ if ($userAccount -eq $null -or ! $userAccount.Id ) {
403+ $userAccount = (Get-AzADUser - UserPrincipalName (Get-AzContext ).Account)
404+ }
405+ if ($userAccount -eq $null -or ! $userAccount.Id ) {
406+ throw " Failed to find entra object ID for the current user"
407+ }
396408 $TestApplicationOid = $userAccount.Id
397409 $TestApplicationId = $testApplicationOid
398410 $userAccountName = $userAccount.UserPrincipalName
0 commit comments