skip to Main Content

I want to find ObjectId of a user, but I can’t use Get-AzADUser module as I don’t have privilege to install this module.

Get-AzRoleAssignment, Get-AzContext is accessible to me

Is there any other way to find ObjectId of a user with any other module.

Any help would be GREATLY appreciated

2

Answers


  1. During my test, you could run the Azure Powershell task with the command Get-AzADUser -DisplayName <String> to query the oid.

    enter image description here
    enter image description here

    ================================================================

    Update on 11/22

    You could also test to use the az command of az ad user list [--display-name] with local cli.

    And it could also be put in Azure DevOps pipeline.

    enter image description here

    Login or Signup to reply.
  2. I agree with Ceeno Qi-MSFT. Alternatively, you can also use below approach:

    I tried to reproduce the same environment and got the below results:

    To get the ObjectId of a user in Azure, you can make use of AzureAD module:

    Install-Module AzureAD -Scope CurrentUser
    Connect-AzureAD
    

    You can make use of either one of the below commands to retrieve ObjectID:

    Get-AzureADUser -ObjectId "XXX@***.onmicrosoft.com"
    OR
    Get-AzureADUser -Filter "userPrincipalName eq 'XXX@***.onmicrosoft.com'"
    

    Response:

    enter image description here

    You can make use of Microsoft Graph API to retrieve the Azure AD Users ObjectID:

    GET https://graph.microsoft.com/v1.0/users/[email protected]?$select=id
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search