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
  1. # Input Parameters  
  2. $teamName="Events2020"  
  3. $channelName="General"  
  4. $credentials=Get-Credential  
  5.  
  6. # Connect to Microsoft Teams  
  7. $connectTeams=Connect-MicrosoftTeams -Credential $credentials  
  8.  
  9. # Get the tenant ID  
  10. $tenantId=$connectTeams.TenantId  
  11.  
  12. # Get the team  
  13. $team=Get-Team -DisplayName $teamName  
  14.  
  15. # Get the Group Id  
  16. $groupID=$team.GroupId  
  17.  
  18. # Get the channel  
  19. $channel=Get-TeamChannel -GroupId $groupID | Where-Object {$_.DisplayName -eq $channelName}  
  20.  
  21. # Get the channel ID  
  22. $channelId=$channel.Id  
  23.  
  24. # Get the Team link  
  25. $teamLink= "https://teams.microsoft.com/l/team/"+$channelId+"/conversations?groupId="+$groupID+"&tenantId="+$tenantId;  
  26. 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.