The -Search parameter in the Get-MgGroupMember cmdlet allows you to search for group members based on specific attributes. This parameter accepts a search string formatted as "<PropertyName>:<SearchValue>", enabling you to filter members whose specified property matches the search value. Commonly searched properties include displayName, mail, and userPrincipalName.
Get-MgGroupMember -GroupId "<GroupId>" -Search "displayName:John" -ConsistencyLevel eventual
This command retrieves members whose display name includes "John".
Get-MgGroupMember -GroupId "<GroupId>" -Search "mail:example.com" -ConsistencyLevel eventual
This command fetches members whose email address includes "example.com".
Get-MgGroupMember -GroupId "<GroupId>" -Search "userPrincipalName:user" -ConsistencyLevel eventual
This command retrieves members whose UPN includes "user".
By utilizing the -Search parameter effectively, administrators can efficiently locate and manage group members based on specific attributes, streamlining group management tasks within Microsoft 365 environments
© m365corner.com. All Rights Reserved. Design by HTML Codex