🔧 New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

How to Use New-MgTeamMember to Add Microsoft Team Members

Managing team memberships efficiently is a core part of Microsoft 365 administration. Whether you’re adding a single user, multiple users, or importing members from a CSV file, the New-MgTeamMember cmdlet makes the process fast and automated through Microsoft Graph PowerShell.

Let’s explore how this cmdlet works and how you can use it to streamline team management.


What is New-MgTeamMember cmdlet?

The New-MgTeamMember cmdlet is part of the Microsoft Graph PowerShell module that allows administrators to add members or owners to a Microsoft Team.

It interacts directly with Microsoft Graph API to add Azure AD users to Teams using their User IDs. You can assign roles (like “owner” or “member”) during the addition, making it an essential tool for automating team management at scale.

In simple terms, it’s the Graph PowerShell equivalent of adding members through the Teams Admin Center — but faster and scriptable.


Why Use New-MgTeamMember cmdlet?

Here are a few reasons why administrators and IT pros prefer using New-MgTeamMember:

  • Automation: Add users or entire groups to Teams without manual clicks.
  • Scalability: Handle multiple team membership updates with a single script.
  • Consistency: Ensure correct role assignments (owner/member) every time.
  • Integration: Combine with CSV imports or directory queries for dynamic updates.

It’s particularly handy when you manage large organizations or frequently onboard users into project-based Teams.


How to Use New-MgTeamMember

The basic syntax of the cmdlet is:

New-MgTeamMember -TeamId  -BodyParameter 

Parameter Explanation:

  • TeamId → The unique identifier (GUID) of the Microsoft Team you want to add members to.
  • BodyParameter → A hashtable that defines the user’s properties, role, and Graph reference using the @odata.bind format.

The BodyParameter is where you specify if the user should be added as a member or an owner.


New-MgTeamMember Examples

Let’s walk through three practical examples, from adding a single user to bulk imports using CSV.


  • Adding a Single User to a Team
  • $params = @{
        "@odata.type" = "#microsoft.graph.aadUserConversationMember"
        roles = @("owner")
        "user@odata.bind" = "https://graph.microsoft.com/v1.0/users('8b081ef6-4792-4def-b2c9-c363a1bf41d5')"
    }
    New-MgTeamMember -TeamId "72a1f6b2-5829-4f26-b3a4-738b4848e248" -BodyParameter $params
                                                

    Explanation:

    This command adds a single user (identified by the User ID) to the specified team and assigns them the owner role.

    If you want to add them as a member instead, simply replace roles = @("owner") with roles = @().

  • Adding Multiple Users to a Team
  • $teamId = "72a1f6b2-5829-4f26-b3a4-738b4848e248"
    $members = @(
        @{
            "@odata.type" = "#microsoft.graph.aadUserConversationMember"
            roles = @("owner")
            "user@odata.bind" = "https://graph.microsoft.com/v1.0/users('8b081ef6-4792-4def-b2c9-c363a1bf41d5')"
        }
        @{
            "@odata.type" = "#microsoft.graph.aadUserConversationMember"
            roles = @()
            "user@odata.bind" = "https://graph.microsoft.com/v1.0/users('9f0e769d-8df1-44f8-bc17-dc7f8881d546')"
        }
    )
    foreach ($member in $members) {
        New-MgTeamMember -TeamId $teamId -BodyParameter $member
    }
                                                

    Explanation:

    This script loops through multiple user records, adding one as an owner and the other as a member.

    It’s useful when you need to assign multiple users different roles at once.

  • Adding Users to a Team from a CSV File
  • If you frequently add members in bulk, using a CSV file is the easiest approach.

    CSV Structure:

    UserId,Role
    8b081ef6-4792-4def-b2c9-c363a1bf41d5,owner
    9f0e769d-8df1-44f8-bc17-dc7f8881d546,member
                                                

    PowerShell Script:

    $teamId = "72a1f6b2-5829-4f26-b3a4-738b4848e248"
    $csvPath = "C:\path\to\your\file.csv"
    $users = Import-Csv -Path $csvPath
    
    foreach ($user in $users) {
        $params = @{
            "@odata.type" = "#microsoft.graph.aadUserConversationMember"
            roles = @($user.Role)
            "user@odata.bind" = "https://graph.microsoft.com/v1.0/users('$($user.UserId)')"
        }
        New-MgTeamMember -TeamId $teamId -BodyParameter $params
    }
                                                

    Explanation:

    This script reads user data from a CSV file and automatically adds each user to the team with the specified role.

    It’s perfect for bulk onboarding scenarios, where adding users one by one would be time-consuming.


Conclusion

The New-MgTeamMember cmdlet is a powerful tool for automating Microsoft Teams member management. Whether you’re adding a single user, multiple users, or importing from a CSV file, it gives you flexibility, speed, and accuracy in managing Teams membership.

  • ✅ Simplify member onboarding
  • ✅ Assign roles programmatically
  • ✅ Reduce manual work and errors

With just a few lines of PowerShell, you can manage Teams memberships at scale — making this cmdlet a must-have for any Microsoft 365 administrator.


Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex