Who Are Microsoft 365 Team Members?
Microsoft 365 Team members are users added to a specific Microsoft Team, giving them access to:
- Chat and video conferencing.
- Shared files and document collaboration via SharePoint.
- Task management using Planner.
- Group calendars and shared mailboxes.
Team members can have different roles, such as owners or standard members, with varying permissions for managing the Team’s settings and content.
Why Use Get-MgTeamMember?
The Get-MgTeamMember cmdlet simplifies the process of retrieving information about members of a Microsoft Team. This cmdlet offers:
- Efficiency: Automate the retrieval of member data for multiple Teams.
- Scalability: Handle large organizations with hundreds of Teams and thousands of members.
- Integration: Combine with other cmdlets for advanced reporting and management workflows.
Setting Up Microsoft Graph PowerShell
Before using the Get-MgTeamMember cmdlet, you must install and configure Microsoft Graph PowerShell:
- Install the Module:
Install-Module Microsoft.Graph -Scope CurrentUser - Connect to Microsoft Graph:
Connect-MgGraph - Disconnect After Use:
Disconnect-MgGraph
Exploring the Get-MgTeamMember Cmdlet
The Get-MgTeamMember cmdlet is used to retrieve details about the members of a specific Microsoft Team. Let’s explore its usage with detailed examples.
Cmdlet Syntax
Get-MgTeamMember [-TeamId <String>] [CommonParameters]
Key Parameters & Configuration Options (Quick Reference)
Understanding the available parameters helps optimize queries and handle large Teams effectively.
| Parameter | Purpose |
| -TeamId | Retrieve members of a specific Team |
| -All | Fetch all members (handles pagination) |
| -Top | Limit number of results |
| -Filter | Filter members based on conditions |
| -Search | Search members by keyword |
| -Property | Select specific properties |
| -ExpandProperty | Expand related objects |
Usage Examples
1. Passing Team ID Directly
To fetch members of a specific Team using its unique ID:
Get-MgTeamMember -TeamId "1cbe8c31-589d-453a-a1e5-045f7f00c967"
2. Passing Team ID When Prompted by Console
If you don’t specify the -TeamId parameter, the cmdlet will prompt you to enter the Team ID interactively:
Get-MgTeamMember
3. Get-MgTeamMember Returns Only Member Ref IDs by Default
By default, Get-MgTeamMember provides member reference IDs (GUIDs), which represent users or service accounts within the Team:
Id ------------------------------------ MCMjMSMjZWFkYTBjY2MtZTQyOC00OWI2LWE2NzYtY2Y4MjRhM2UzODUwIyM3YWM0MDBiMS031 MCMjMSMjZWFkYTBjY2MtZTQyOC00OWI2LWE2NzYtY2Y4MjRhM2UzODUwIyM3YWM0MDBiMS031 MCMjMSMjZWFkYTBjY2MtZTQyOC00OWI2LWE2NzYtY2Y4MjRhM2UzODUwIyM3YWM0MDBiMS031
4. Get Detailed User Information
To fetch detailed information (e.g., display names, UPNs, emails, including the UserID) of Team members, combine Get-MgTeamMember with Get-MgUser:
$teamId = "9f47ec97-db44-41db-8867-3793cff0a49a"
$teamMembers = Get-MgTeamMember -TeamId $teamId -All
$teamMemberDetails = foreach ($member in $teamMembers) {
$additionalProps = $member.AdditionalProperties
$userId = $additionalProps["userId"]
if ($userId -ne $null -and $userId -ne "") {
$user = Get-MgUser -UserId $userId
[PSCustomObject]@{
Id = $user.Id
DisplayName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
}
}
}
$teamMemberDetails | Format-Table -AutoSize
When Should You Use Get-MgTeamMember?
Use the Get-MgTeamMember cmdlet in the following scenarios:
- Auditing Team memberships for compliance and governance
- Generating membership reports for administrators
- Validating access control for sensitive Teams
- Tracking user participation across Teams
Get-MgTeamMember vs Related Cmdlets
| Cmdlet | Purpose | When to Use |
| Get-MgTeamMember | Retrieve team members | Reporting & auditing |
| Add-MgTeamMember | Add users to Teams | Provisioning |
| Remove-MgTeamMember | Remove users | Access control |
| Get-MgTeam | Retrieve Team details | Metadata & settings |
Real-World Automation Scenarios
-
Membership Audit & Compliance
- Identify who has access to critical Teams
- Detect unauthorized users
-
Exporting Team Members to Reports
- Retrieve members using -All
- Export to CSV for reporting
-
Access Validation During Onboarding/Offboarding
- Ensure new users are added correctly
- Verify removed users no longer have access
-
Cross-Team Membership Analysis
- Combine with Get-MgTeam to loop through Teams
- Build tenant-wide membership reports
Common Limitations & Considerations
Strengths
- Provides detailed membership information/li>
- Supports filtering and pagination
- Essential for reporting and audits
Limitations
- Requires TeamId (no direct “get all members across all Teams” in one call)
- Does not return all user attributes by default
- Large Teams require pagination handling
Pro Tips for Using Get-MgTeamMember
- Use -All for large Teams to avoid missing members
- Combine with Get-MgTeam for tenant-wide reporting
- Use Select-Object to extract only required fields
- Export results to CSV for audits
- Handle pagination carefully to avoid incomplete data
Example: End-to-End Teams Membership Reporting
- Retrieve all Teams using Get-MgTeam -All
- Loop through each Team
- Fetch members using Get-MgTeamMember
- Export results to CSV
- Analyze using Power BI
Frequently Asked Questions (FAQs)
- What is Get-MgTeamMember used for?
Get-MgTeamMember is used to retrieve members of a Microsoft Team using Graph PowerShell for auditing and reporting. - Can I retrieve all members of a Team?
Yes, using the -All parameter, you can retrieve all members, including large Teams - What permissions are required?
You need permissions such as TeamMember.Read.All or Group.Read.All, depending on your scope. -
Can I get members of all Teams at once?
Not directly—you need to loop through Teams using Get-MgTeam and then call Get-MgTeamMember. - Does this cmdlet return user details?
It returns membership details, but for full user properties, you may need additional cmdlets like Get-MgUser.
Best Practices for Get-MgTeamMember
- Limit Scope for Efficiency: Use filters or parameters to focus on specific Teams or subsets of data, reducing execution time.
- Combine with Other Cmdlets: Integrate Get-MgTeamMember with cmdlets like Get-MgUser or Remove-MgTeamMember for advanced workflows.
- Log Your Actions: Keep logs of your scripts and results for audit purposes, especially when handling sensitive membership data.
- Secure Your Session: Always disconnect from Microsoft Graph after completing tasks to protect your admin account.
Conclusion
The Get-MgTeamMember cmdlet is an invaluable tool for Microsoft 365 administrators, providing a powerful way to query Team memberships. Whether you’re retrieving basic member IDs, fetching detailed user information, or integrating the cmdlet into larger workflows, Get-MgTeamMember simplifies membership management and enhances productivity.
By mastering this cmdlet and following best practices, you can streamline your administrative tasks and ensure effective Team management across your organization.
🚀 Community Edition Released!
Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.
Get it on GitHub Know More