How to get CompanyName with Microsoft Graph powershell module

Cai, Xiaoxiao/蔡 筱筱 21 Reputation points
2022-11-23T12:37:38.113+00:00

With the Azure AD powershell module,the CompanyName can get from command:

> Get-AzureADGroupMember -ObjectId ×××××××××× -All $True | Where-Object {$_.AssignedLicenses -ne $null} | Select-Object -Property UserPrincipalName,CompanyName,AssignedLicenses  
  
UserPrincipalName               CompanyName AssignedLicenses  
-----------------               ----------- ----------------  
user01@×××.onmicrosoft.com  Company01    {class AssignedLicense {...  
user02@×××.onmicrosoft.com  Company02    {class AssignedLicense {...  

How to get the CompanyName with Microsoft Graph powershell module?

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

Accepted answer
  1. Srinivasa Rao Darna 6,686 Reputation points Microsoft Vendor
    2022-11-23T15:09:45.68+00:00

    Hello @Cai, Xiaoxiao/蔡 筱筱 ,

    You can use below Microsoft Graph API to get group members and selected properties such as companyName.

    GET https://graph.microsoft.com/v1.0/groups/{group-id}/members?$select=userPrincipalName,companyName,assignedLicenses  
    

    Equivalent Graph PowerShell:

    Import-Module Microsoft.Graph.Groups  
     
    Get-MgGroupMember -GroupId $groupId -Property "userPrincipalName,companyName,assignedLicenses"  
    

    Additional reference:
    group-list-members
    msgraph-sdk-powershell

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


0 additional answers

Sort by: Most helpful