Connect to AzureAD

Moonlight 176 Reputation points


I tried to connect to AzureAD from my powershell with global admin user but when i tried to apply any Azure powershell command i have the below error

PS C:\Windows\system32> Get-AzureADUser -Top 10
Get-AzureADUser : Error occurred while executing GetUsers
Code: Authentication_Unauthorized
Message: User was not found.
RequestId: afeb378f-4388-4ae2-88bf-653410122329
DateTimeStamp: Sun, 13 Dec 2020 12:51:32 GMT
HttpStatusCode: Forbidden
HttpStatusDescription: Forbidden
HttpResponseStatus: Completed
At line:1 char:1

  • Get-AzureADUser -Top 10
  • ~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : NotSpecified: (:) [Get-AzureADUser], ApiException
  • FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetUser
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,396 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points

    You need first to authenticate to Azure.
    I would recommend to use latest powershell module for Azure Az.
    To connect to azure you need to use:


    To get users you have:

    1 person found this answer helpful.
    0 comments No comments

  2. JamesTran-MSFT 36,361 Reputation points Microsoft Employee

    Thank you for the detailed post! If you have the most recent AzureAD PS modules, you can try the below to hopefully resolve your issue.

    TS Steps:
    The accounts I used - Outlook user and Tenant specific user, both Global Admins.

    I replicated the error that you are receiving by signing into my Outlook account.

    I created a new test user, within my tenant and re-tried the operation, which was successful.

    I hope this helps! If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.


    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    1 person found this answer helpful.

  3. hitokiri8384 1 Reputation point

    Hi. Im getting the same error. I recently created this azure free account. Im only getting this error when I user powershell ISE or visual stuido code apps on my computer. When I try the same using the cloudshell on azure it is working. can you help me please? .com

    0 comments No comments

  4. amit tiwari 1 Reputation point

    I was also facing the same issue a few days back
    steps to resolve it
    step1-cross-check tenant id from your ADD account and Tenant ID which you get after connection,If both are different then you have to modify your connect-AzureAD command

    step2-you need to use the below command to rectify it and everything will work like a charm.

    connect-AzureAD -TenantID <you tenant id from ADD acount>

    0 comments No comments