How to get teams Group Ids

HASSAN BIN NASIR DAR 391 Reputation points
2023-03-09T10:20:33.51+00:00

Hi

I have 4000+ Microsoft Teams in my tenant. I want to get teams Ids (Group ids)for specific 300 Microsoft Teams? I have csv file for these 300 teams.

Regards

Microsoft Teams | Microsoft Teams for business | Other
{count} votes

Accepted answer
  1. Michael-6094 185 Reputation points
    2023-03-10T15:10:36.2866667+00:00

    Hi @Chapter7-2723,

    thank you for your response. I've adjusted the PS script a little bit:

    # Set the path to the CSV file containing the Teams names
    $csvPath = "C:\Temp\TeamsGroupID.csv"
    
    # Import the Teams names from the CSV file
    $teams = Import-Csv $csvPath
    
    # Create an empty array to store the results
    $results = @()
    
    # Loop through each Team and get the Team ID
    foreach ($team in $teams) {
        $teamName = $team.DisplayName
        $teamId = (Get-Team -DisplayName $teamName).GroupId
        $results += [PSCustomObject]@{
            TeamName = $teamName
            TeamId = $teamId
        }
    }
    
    # Export the results to a CSV file
    $results | Export-Csv "C:\Temp\TeamsGroupIDExport.csv" -NoTypeInformation
    
    

    be sure to adjust your path for import and export.

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


3 additional answers

Sort by: Most helpful
  1. Michael-6094 185 Reputation points
    2023-03-09T14:45:31.8766667+00:00

    hi,

    you can use the following:

    be sure to first connect to the Teams via Connect-MicrosoftTeams.

     $Teams=Import-csv -path C:\TeamsGroupID.csv
    Foreach($Team in $Teams){
    $Variable=get-team -DisplayName $Team | select GroupID,Displayname
    } 
    
    

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

    1 person found this answer helpful.

  2. HASSAN BIN NASIR DAR 391 Reputation points
    2023-03-10T14:07:37.0933333+00:00

    Hi Michael,

    Thanks for your message.

    I used this script but could not get expected result. I am attaching a snapshot of export file. I can see only Microsoft teams name but not Group ID.

    Screenshot-groupID

    $teams = Import-Csv -Path "c:\test\DPname.csv"

    Foreach($Team in $Teams){

    $Variable=get-team -DisplayName $Team | select GroupID,Displayname

    }

    $teams | Export-Csv -Path "c:\test\DPwithguid.csv" -NoTypeInformation

    0 comments No comments

  3. HASSAN BIN NASIR DAR 391 Reputation points
    2023-03-14T09:06:09.2733333+00:00

    Hi Michael,

    Can you please answer my another question on this link:

    https://learn.microsoft.com/en-us/answers/questions/1189355/how-to-check-users-microsoft-teams-membership

    Regards

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.