Error occurred while executing GetUsers

Jairo Javier Baleta Cali 216 Reputation points
2025-04-21T17:14:19.9266667+00:00

Good afternoon everyone.

Greetings.

I need help for an error that the Get-AzureADUser command started throwing:

Connect-AzureAD -TenantId $tenantid -CertificateThumbprint $appazurethumbprint -ApplicationId $appazureid
Get-AzureADUser -All $True

The error is the following:

Microsoft.Open.AzureAD16.Client.ApiException: Error occurred while executing GetUsers
Code: Authentication_Unauthorized
Message: Access blocked to AAD Graph API for this application. https://aka.ms/AzureADGraphMigration.
HttpStatusCode:Forbidden
HttpStatusDescription: Forbidden
HttpResponseStatus: Completed
 at Microsoft.Open.AzureAD16.Client.Configuration.<>c.<.cctor>b__47_0(String methodName, IRestResponse response) in C:\__w\1\s\src\dev\PowerShell.V2\AzureAD16.Client\Client\Configuration.cs:line 188
 at Microsoft.Open.AzureAD16.Api.UserApi.GetUsersWithHttpInfo(String tenantId, String authorization, String cmdletName, String clientRequestId, String apiVersion, String objectId, Nullable`1 all, Nullable`1
top, String skiptoken, String filter, String orderby) in C:\__w\1\s\src\dev\PowerShell.V2\AzureAD16.Client\Api\UserApi.cs:line 4613
 at Microsoft.Open.AzureAD16.PowerShell.GetUsers.ProcessRecord() in C:\__w\1\s\src\dev\PowerShell.V2\AzureAD16.PowerShell\AzureAD16.PowerShell.AutoGen\API\UserApi.cs:line 2044
 at System.Management.Automation.Cmdlet.GetResults()
 at System.Management.Automation.Cmdlet.<Invoke>d__40.MoveNext()
 at System.Management.Automation.MshCommandRuntime._WriteObjectsSkipAllowCheck(Object sendToPipeline)
 at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
 at System.Management.Automation.MshCommandRuntime.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
 at System.Management.Automation.Cmdlet.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
 at Microsoft.Open.AzureAD16.PowerShell.GetUser.ProcessRecord() in C:\__w\1\s\src\dev\PowerShell.V2\AzureAD16.PowerShell\AzureAD16.PowerShell.AutoGen\API\UserApi.cs:line 258
 at System.Management.Automation.CommandProcessor.ProcessRecord())

App permissions are as follows:Captura de pantalla 2024-07-10 084913

I hope you can help me help.

Sincerely,

Jairo Baleta

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,915 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.