@@ -353,15 +353,12 @@ try {
353353 # Make sure the provisioner OID is set so we can pass it through to the deployment.
354354 if (! $ProvisionerApplicationId -and ! $ProvisionerApplicationOid ) {
355355 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 ) {
362359 throw " Failed to find entra object ID for the current user"
363360 }
364- $ProvisionerApplicationOid = $user .Id
361+ $ProvisionerApplicationOid = $userAccountId
365362 } elseif ($context.Account.Type -eq ' ServicePrincipal' ) {
366363 $sp = Get-AzADServicePrincipal - ApplicationId $context.Account.Id
367364 $ProvisionerApplicationOid = $sp.Id
@@ -431,17 +428,14 @@ try {
431428 Write-Warning " The specified TestApplicationId '$TestApplicationId ' will be ignored when -ServicePrincipalAutth is not set."
432429 }
433430
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 ) {
440435 throw " Failed to find entra object ID for the current user"
441436 }
442- $TestApplicationOid = $userAccount .Id
437+ $TestApplicationOid = $userAccountId
443438 $TestApplicationId = $testApplicationOid
444- $userAccountName = $userAccount.UserPrincipalName
445439 Log " User authentication with user '$userAccountName ' ('$TestApplicationId ') will be used."
446440 }
447441 # If user has specified -ServicePrincipalAuth
0 commit comments