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:
Connect-AzAccount
To get users you have:
Get-AzADUser
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
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
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:
Connect-AzAccount
To get users you have:
Get-AzADUser
@Moonlight
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.
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? carlo_vergara@harsh.com .com
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>