Microsoft Teams Usage Report

Microsoft Teams Usage Report

Microsoft Teams Usage Report

I’ve created a small script that will create an HTML report of all Teams in your organisation, including their owners and members. Nothing spectacular but very usefull Microsoft Teams Usage Report.

Governance for Microsoft Teams is very important and if you didn’t think of it at the beginning, this can help you clean up the mess. Also, be sure to have a look at the Governance quick start for Microsoft Teams.

### Microsoft Teams PowerShell Module Installed? ###
$MSTeamsModule = Get-Module -ListAvailable MicrosoftTeams
if (!$MSTeamsModule) {
    Write-Host "MicrosoftTeams PowerShell Module not installed." -ForegroundColor Yellow
    Write-Host "Install with 'Install-Module -Name MicrosoftTeams'" -ForegroundColor Yellow

$Style = "
    TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
    TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#778899;vertical-align: top;text-align: left;}
    TD{border-width: 1px;padding: 3px;border-style: solid;border-color: black;vertical-align: top;text-align: left;}

$MSTeams = Get-Team

$counter = 0
$object = @(foreach ($MSTeam in $MSTeams) {
    Write-Progress -Activity 'Processing Teams..' -CurrentOperation $MSTeam.DisplayName -PercentComplete (($counter / $MSTeams.Count) * 100)

    $TUser = Get-TeamUser -GroupId $MSTeam.GroupId
    $owners = (($TUser | ?{$_.Role -eq 'Owner'}).User) -join ', '
    $members = (($TUser).User) -join ', '

    ## Create Custom Object
        'DisplayName' = $MSTeam.DisplayName
        'Description' = $MSTeam.Description
        'Visibility' = $MSTeam.Visibility
        'Archived' = $MSTeam.Archived
        'UserCount' = ($TUser.UserID).Count
        'Owner' = $owners
        'Members' = $members

    $counter ++

$object | ConvertTo-Html -Property DisplayName,Description,Visibility,Archived,UserCount,Owner,Members -Head $Style | Out-File -FilePath TeamsReports.html

Leave a Reply

Your email address will not be published. Required fields are marked *