@@ -353,15 +353,12 @@ try {
353
353
# Make sure the provisioner OID is set so we can pass it through to the deployment.
354
354
if (! $ProvisionerApplicationId -and ! $ProvisionerApplicationOid ) {
355
355
if ($context.Account.Type -eq ' User' ) {
356
- # Support corp tenant and TME tenant user id lookups
357
- $user = Get-AzADUser - Mail $context.Account.Id
358
- if ($null -eq $user -or ! $user.Id ) {
359
- $user = Get-AzADUser - UserPrincipalName $context.Account.Id
360
- }
361
- if ($null -eq $user -or ! $user.Id ) {
356
+ # HomeAccountId format is '<object id>.<tenant id>'
357
+ $userAccountId = (Get-AzContext ).Account.ExtendedProperties.HomeAccountId.Split(' .' )[0 ]
358
+ if ($null -eq $userAccountId ) {
362
359
throw " Failed to find entra object ID for the current user"
363
360
}
364
- $ProvisionerApplicationOid = $user .Id
361
+ $ProvisionerApplicationOid = $userAccountId
365
362
} elseif ($context.Account.Type -eq ' ServicePrincipal' ) {
366
363
$sp = Get-AzADServicePrincipal - ApplicationId $context.Account.Id
367
364
$ProvisionerApplicationOid = $sp.Id
@@ -431,17 +428,14 @@ try {
431
428
Write-Warning " The specified TestApplicationId '$TestApplicationId ' will be ignored when -ServicePrincipalAutth is not set."
432
429
}
433
430
434
- # Support corp tenant and TME tenant user id lookups
435
- $userAccount = (Get-AzADUser - Mail (Get-AzContext ).Account.Id)
436
- if ($null -eq $userAccount -or ! $userAccount.Id ) {
437
- $userAccount = (Get-AzADUser - UserPrincipalName (Get-AzContext ).Account)
438
- }
439
- if ($null -eq $userAccount -or ! $userAccount.Id ) {
431
+ $userAccountName = (Get-AzContext ).Account.Id
432
+ # HomeAccountId format is '<object id>.<tenant id>'
433
+ $userAccountId = (Get-AzContext ).Account.ExtendedProperties.HomeAccountId.Split(' .' )[0 ]
434
+ if ($null -eq $userAccountId ) {
440
435
throw " Failed to find entra object ID for the current user"
441
436
}
442
- $TestApplicationOid = $userAccount .Id
437
+ $TestApplicationOid = $userAccountId
443
438
$TestApplicationId = $testApplicationOid
444
- $userAccountName = $userAccount.UserPrincipalName
445
439
Log " User authentication with user '$userAccountName ' ('$TestApplicationId ') will be used."
446
440
}
447
441
# If user has specified -ServicePrincipalAuth
0 commit comments