Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save page2me/a7b076c0bcaf323ca83c1e4b2391de80 to your computer and use it in GitHub Desktop.
Save page2me/a7b076c0bcaf323ca83c1e4b2391de80 to your computer and use it in GitHub Desktop.

Revisions

  1. @mrik23 mrik23 revised this gist Sep 3, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions MicrosoftTeams-GetTeamLink.ps1
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ $teamDisplayName = ""
    $groupID = ""

    #Team link template
    $teamLink = "https://teams.microsoft.com/l/team/<ThreadId>/conversations?groupId=<GroupId>&tenantId=<TenantId>"
    $teamLinkTemplate = "https://teams.microsoft.com/l/team/<ThreadId>/conversations?groupId=<GroupId>&tenantId=<TenantId>"

    #Connect to Microsoft Teams
    $connectTeams = Connect-MicrosoftTeams
    @@ -23,4 +23,5 @@ $team = Get-Team | Where-Object {$_.DisplayName -eq $teamDisplayName -or $_Group
    $channel = Get-TeamChannel -GroupId $team.GroupId | Where-Object {$_.DisplayName -eq "General"} | Select-Object -First 1

    #Construct the team link
    $teamLink.Replace("<ThreadId>",$channel.Id).Replace("<GroupId>",$team.GroupId).Replace("<TenantId>",$connectTeams.TenantId)
    $teamLink = $teamLinkTemplate.Replace("<ThreadId>",$channel.Id).Replace("<GroupId>",$team.GroupId).Replace("<TenantId>",$connectTeams.TenantId)
    $teamLink
  2. @mrik23 mrik23 created this gist Sep 3, 2018.
    26 changes: 26 additions & 0 deletions MicrosoftTeams-GetTeamLink.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <#
    Script to construct team link using Microsoft Teams PowerShell module.
    https://docs.microsoft.com/en-us/powershell/teams/intro
    https://www.powershellgallery.com/packages/MicrosoftTeams/
    #>

    #Enter team display name or group ID
    $teamDisplayName = ""
    $groupID = ""

    #Team link template
    $teamLink = "https://teams.microsoft.com/l/team/<ThreadId>/conversations?groupId=<GroupId>&tenantId=<TenantId>"

    #Connect to Microsoft Teams
    $connectTeams = Connect-MicrosoftTeams

    #Retrieve the team via display name or group ID
    $team = Get-Team | Where-Object {$_.DisplayName -eq $teamDisplayName -or $_GroupId -eq $groupID} | Select-Object -First 1

    #Retrieve team channel General (can be replaced by another Channel if needed)
    $channel = Get-TeamChannel -GroupId $team.GroupId | Where-Object {$_.DisplayName -eq "General"} | Select-Object -First 1

    #Construct the team link
    $teamLink.Replace("<ThreadId>",$channel.Id).Replace("<GroupId>",$team.GroupId).Replace("<TenantId>",$connectTeams.TenantId)