Getting non-common attributes from AD B2C users with PowerShell

David Wong 51 Reputation points
2022-12-09T13:21:59.093+00:00

I would like to retrieve the following attributes: "createdDateTime, extension_xxxxxx_yyyyy, identities". With Graph Explorer, I could do this with:

https://graph.microsoft.com/v1.0/users?$select=createdDateTime extension_xxxxxx_yyyyy, identities

Then, I tried the snippet generated by Graph Explorer for PowerShell

Get-MgUser -Property “createdDateTime,+extension_xxxxxx_yyyyy,identities”   

I got the following error:

Parsing OData Select and Expand failed: Syntax error: character '+' is not valid at position 17 in 'createdDateTime, +exten ……

I removed the “+” and retried, it had no error, but all the returned fields were blank.
I am using Microsoft Graph PowerShell SDK 1.18

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,593 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,184 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,346 Reputation points
    2022-12-12T09:04:59.5+00:00

    Hi @David Wong

    The extension_xxxxxx_yyyyy is not a built-in parameter for the user, it is automatically categorized into AdditionalProperties when you call it using Graph Power Shell.

    Import-Module Microsoft.Graph.Users  
      
    Select-MgProfile -Name "beta"  
      
    Connect-MgGraph -Scopes "User.Read.All"  
      
    Get-MgUser -All | Format-List id,createdDateTime,identities,AdditionalProperties  
    

    269617-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.