Forum Discussion
LeeGee76
Jan 18, 2023Copper Contributor
Using Get-AADGroupMember to show Groups only
Hi everyone, I'm looking for some help please... I've been trying to run some powershell script to get a list of members from an Intune Group, however I want to filter on group members only. ...
RGijsbersRademakers
Jan 22, 2023Iron Contributor
Hi LeeGee76,
Because the Azure AD PowerShell module will be deprecated later this year, I would focus on the Microsoft Graph PowerShell module to be future proof. You can use the following to get the list you want:
Install-Module Microsoft.Graph.Groups
Import-Module Microsoft.Graph.Groups
Connect-MgGraph
(Get-MgGroupMember -GroupId xxxxxxx | where {$_.AdditionalProperties.'@odata.type' -contains '#microsoft.graph.group'}).AdditionalProperties.displayName
or
$MemberGroups = Get-MgGroupMember -GroupId xxxxxxx | where {$_.AdditionalProperties.'@odata.type' -contains '#microsoft.graph.group'}
$MemberGroups.AdditionalProperties.displayName
The Microsoft Graph PowerShell generates the output a bit different from what you're used to. Most information is within the Additional Properties.
I hope this helps.
Regards,
Ruud