Hello Jairo Javier Baleta Cali,
I understand you're getting an error when running the Get-AzureADUser
command. I ran your script in my test environment and saw the same error.
This happens because the AzureAD
module uses an old API (Azure AD Graph) that Microsoft has started blocking.
Since February 1, 2025, apps must be updated to allow temporary access to this old API. If not, they get a 403 Unauthorized
error. This temporary access will only work until June 30, 2025. After that, the old API will stop working for all apps.
If you need more time, you can turn on this access by updating the app settings. Microsoft explains how to do this here: Manage application authenticationBehaviors - Microsoft Graph
The better option is to switch to Microsoft Graph, which is the new and supported way to connect. To do that, first install the new module:
Install-Module Microsoft.Graph -Scope CurrentUser
Then update your script like this:
$tenantid = "tenantId"
$appazurethumbprint = "thumbprint"
$appazureid = "appId"
$cert = Get-Item "Cert:\CurrentUser\My\$appazurethumbprint"
Connect-MgGraph -TenantId $tenantid -ClientId $appazureid -Certificate $cert
Get-MgUser -All
Make sure the app has the right Graph permissions like User.Read.All
or Directory.Read.All
of Application type, and that admin consent has been given.
Let me know if you have any other questions or need any further assistance.
Hope this clarifies things a bit!
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful, which may help members with similar questions.
If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.