Ok, I would verify that you are logged in with an account that has permissions to run these queries first. I know that sounds obvious, but thats the sort of error you would get if not.
Powershell Get-AzureADUser - Error occurred while executing GetUser
Hello,
I would like to try to get information about my user, but when I try to use Get-AzureADUser -ObjectId <ObjectID> I got this:
Get-AzureADUser : Error occurred while executing GetUser
Code: Request_ResourceNotFound
Message: Resource <ObjectID> does not exist or one of its queried reference-property objects are not present.
RequestId: cf1630bf-24cb-43b9-a23e-1483e7e4882c
DateTimeStamp: Mon, 15 Nov 2021 11:02:59 GMT
HttpStatusCode: NotFound
HttpStatusDescription: Not Found
HttpResponseStatus: Completed
At line:1 char:1
+ Get-AzureADUser -ObjectId <ObjectID>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureADUser], ApiException
+ FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetUser
I connect to AzureAD with 2 commands:
- Connect-AzureAD -TenantId
- Connect-AzureAD
But I have errors with this command. I need this to check problems with Exchange hybrid
(Get-AzureADUser -ObjectId <ObjectID>).Errors.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription
When I try to get only Get-AzureADUser I've got results:
Any suggestion?
Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Entra Microsoft Entra ID
4 answers
Sort by: Most helpful
-
Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
2021-11-15T12:45:11.593+00:00 -
Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
2021-11-15T12:59:27.777+00:00 The syntax/properties you are trying to reference are for the Get-MsolUser cmdlet, you cannot just replace it with the Get-AzureADUser and expect it to work :) Errors/ErrorDetails and so on is not exposed via the Get-AzureADUser cmdlet.
-
Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
2021-11-15T13:04:15.27+00:00 Ok, but if its failing with Get-AzureADUser -ObjectId <ObjectID> with that error, then the UPN you are entering must not exist.
try this as a test:
Get-AzureADUser -SearchString <DisplayName of User>
-
Limitless Technology 39,916 Reputation points
2021-11-16T08:45:38.4+00:00 Hi there,
This error means that you are connecting to Azure AD without privileges or you are connecting to the wrong Tenant ID. To ensure connection to the expected Azure AD Domain, the tenant ID must specified. The tenant ID can be retrieved using the Get-AzureRmContext cmdlet. Then indicate this ID and try running the command again.
--If the reply is helpful, please Upvote and Accept it as an answer--