Member-only story
Retrieve Additional User Properties Beyond the Defaults in Microsoft Graph PowerShell
When working with Microsoft Graph PowerShell, the Get-MgUser
cmdlet is used to fetch user details from Azure Entra ID. By default, only a basic set of properties are retrieved, such as DisplayName
, Id
, Mail
, and UserPrincipalName
. However, you might want to retrieve additional properties that are not part of the default set, like companyName
or givenName
.
In this blog, learn how to retrieve non-default user properties, such as companyName
, from Azure Entra ID using Microsoft Graph PowerShell. We'll cover how to specify custom properties beyond the default set
Step-by-Step Guide
1. Install the Microsoft Graph PowerShell Module
Before fetching data from the Graph API, ensure that the Microsoft Graph PowerShell SDK is installed. If it’s not already installed, you can install it using:
Install-Module Microsoft.Graph -Scope CurrentUser
2. Connect to Microsoft Graph
To interact with Microsoft Graph, you need to authenticate using Connect-MgGraph
. You will also need to specify the necessary permission scope. For retrieving detailed properties like companyName
, you might need User.Read.All
:
Connect-MgGraph -Scopes "User.Read.All"