Obtain the ExtensionProperty with Get-MgUser as if obtained with the Get-AzureADUser command through an App with Entra ID

Jairo Javier Baleta Cali 241 Reputation points
2025-04-29T20:29:39.94+00:00

Good afternoon.

Greetings.

Due to an error that is throwing me the Get-AzureADUser command to access an App with Entra ID, I can continue using it for other implementations: https://learn.microsoft.com/en-us/answers/questions/2259866/error-occurred-while-executing-getusers.

As an additional option you will find Get-MgUser which displays user information. But I have not been able to consult the extended attributes that are loaded from Onpremise. Find the OnPremisesExtensionAttributes.ExtensionAttribute1 property but it shows me the information.

How can I load the extended attribute information loaded from the Onpremise Active Directory (extension_<Id>_msDS_cloudExtensionAttribute)?

How can I solve the incident?

I hope you can help me.

Thank you very much.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,541 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SrideviM 2,785 Reputation points Microsoft External Staff
    2025-05-02T09:34:18.3433333+00:00

    Hello Jairo Javier Baleta Cali,

    I understand you are trying to retrieve extended attribute values using Get-MgUser, similar to how you previously used Get-AzureADUser. Since Azure AD Graph has been deprecated, switching to Microsoft Graph is the right approach.

    If you're referring to attributes like extensionAttribute1, which are synced from your on-premises Active Directory through Microsoft Entra Connect, you can access them through the onPremisesExtensionAttributes property.

    Here's how you can retrieve those values:

    (Get-MgUser -UserId "******@domain.com" -Property "onPremisesExtensionAttributes").onPremisesExtensionAttributes
    

    This will return all extension attributes from 1 to 15, assuming they are properly configured and synced.

    User's image

    If you're referring to a custom attribute registered through an app as a schema extension (for example, extension_<AppId>_sampleid), you can retrieve it like this:

    $customProp = "extension_{appId}_sampleid1"
    
    $user = Get-MgUser -UserId "******@domain.com" -Property $customProp
    $user.AdditionalProperties[$customProp]
    

    User's image

    For this to work, the custom extension must exist on the user object. 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.

    User's image

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.