Home

Teams: PowerShell script to get the list of Teams associated with a dedicated user

Highlighted
Fabrice Romelard
MVP

A basic question could be to get all the information associated with one user account in the Office 365 Teams like:

  • Which are the Teams he can connect?
  • What are the permission set associated with these Teams?
  • What are the cannel placed into these Teams?
  • What is the configuration of these Teams?

A solution could be to use the PowerShell module developed around Teams:

 

That solution is quite limited in term of action, but those questions can get answer with.

To do that I created a simple PowerShell script in which you can change the login to connect and login of people you are questioning. To execute that script you need to have high level permissions and a Teams license associated to the used account too.

 

Import-Module MicrosoftTeams

#$cred = Get-Credential
#$username = $cred.UserName
#Connect-MicrosoftTeams
#Get-Command -Module MicrosoftTeams 

[string]$username = "YourAdminAccount@yourdomain.com"
[string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt"
$secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath)
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd

Connect-MicrosoftTeams -Credential $cred


[string]$LoginToUser =  "LogintoCheck@yourdomain.com"

Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green
Write-Host " => Login to check for the Teams:", $LoginToUser  -ForegroundColor Green

$ListOfMyTeams = Get-Team  -user $LoginToUser

foreach($MyTeams in $ListOfMyTeams)
{
	Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green
	Write-Host "    ===-> Teams Name:", $MyTeams.GroupId, "- Name:", $MyTeams.DisplayName, "- Description:", $MyTeams.Description  -ForegroundColor Yellow
    
    Write-Host "    ===-> Get-TeamFunSettings:" -ForegroundColor Yellow
    Get-TeamFunSettings -GroupId $MyTeams.GroupId

    Write-Host "    ===-> Get-TeamGuestSettings:" -ForegroundColor Yellow
    Get-TeamGuestSettings -GroupId $MyTeams.GroupId

    Write-Host "    ===-> Get-TeamMemberSettings:" -ForegroundColor Yellow
    Get-TeamMemberSettings -GroupId $MyTeams.GroupId

    Write-Host "    ===-> Get-TeamMessagingSettings:" -ForegroundColor Yellow
    Get-TeamMessagingSettings -GroupId $MyTeams.GroupId

    Write-Host "    ===-> Get-TeamUser:" -ForegroundColor Yellow
    Get-TeamUser -GroupId $MyTeams.GroupId  | Format-Table
    

    $MyListOfChannelList = Get-TeamChannel -GroupId $MyTeams.GroupId
    foreach($MyChannel in $MyListOfChannelList)
    {
      
	    Write-host "      ------------------ " -ForegroundColor green
	    Write-Host "      ===-> Channel Name:", $MyChannel.Id, "- Name:", $MyChannel.DisplayName, "- Description:", $MyChannel.Description  -ForegroundColor Magenta
        
        #$MyChannel | Get-Member
    
    }

	Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green
}

Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green

You can customize that script as much as you want.

 

If you need more management or action around Teams, you have to look the Office Graph Usage instead of that module.

 

Fabrice Romelard

 

Sources used to build it:

French version:

1 Reply
Related Conversations
Sharing a Teams Calendar
Michael Krueger in Microsoft Teams on
15 Replies
Teams Crashes on Startup
Slarti in Microsoft Teams on
41 Replies
Block Group Communications
danthetechman in Microsoft Teams on
9 Replies