How To Get Direct Link To Team In Microsoft Teams Using PowerShell

In this blog, you will see how to get a direct link to a team in Microsoft Teams using PowerShell.

Navigate to Microsoft Teams, click more options and then click Get link to team.

How To Get Direct Link To Team In Microsoft Teams Using PowerShell

Link

https://teams.microsoft.com/l/team/19%3a19a0e70002ad40fe95aaacc04221b866%40thread.skype/conversations?groupId=651e1d9d-1169-48d7-9ad7-59e834a7e7ea&tenantId=e8e6d018-a834-406b-9f43-2e94ae425876

Link Format

https://teams.microsoft.com/l/team/<ChannelID>/conversations?groupId=<GroupID>&tenantId=<TenantID>

Prerequisites

Install the Teams Cmdlets module.

Reference URL - https://www.powershellgallery.com/packages/MicrosoftTeams/1.0.5

PowerShell Script

# Input Parameters  
$teamName="Events2020"  
$channelName="General"  
$credentials=Get-Credential  

# Connect to Microsoft Teams  
$connectTeams=Connect-MicrosoftTeams -Credential $credentials  

# Get the tenant ID  
$tenantId=$connectTeams.TenantId  

# Get the team  
$team=Get-Team -DisplayName $teamName  

# Get the Group Id  
$groupID=$team.GroupId  

# Get the channel  
$channel=Get-TeamChannel -GroupId $groupID | Where-Object {$_.DisplayName -eq $channelName}  

# Get the channel ID  
$channelId=$channel.Id  

# Get the Team link  
$teamLink= "https://teams.microsoft.com/l/team/"+$channelId+"/conversations?groupId="+$groupID+"&tenantId="+$tenantId;  
Write-Host -F Green $teamLink  

Result

How To Get Direct Link To Team In Microsoft Teams Using PowerShell

Summary

In this blog, you saw how to get a direct link to a team in Microsoft Teams using PowerShell.