Thursday, 26 December 2024

Microsoft Teams Report with Member Details

 param(

$Output,
$TotalTeams,
$Mem,
$Created,
$CurrentDate
)

$Admin = "admin@email.com"
Connect-AzureAD
Connect-MicrosoftTeams
Connect-ExchangeOnline -UserPrincipalName $Admin
Connect-IPPSSession -UserPrincipalName $Admin

$TotalTeams= Get-Team

$Output = [System.Collections.ArrayList]@()
$Output.Clear()

Foreach($Teams in $TotalTeams){
    $Mem = Get-TeamUser -GroupId $Teams.GroupId
    $Created = (Get-UnifiedGroup $Teams.GroupId).WhenCreated
    foreach($m in $Mem){
        $Property=[pscustomobject][ordered]@{
            TeamName = $Teams.DisplayName
            Member = $m.name
            Email = $m.user
            Role = $m.role
            CreationDate = $Created
            Description = $Teams.Description
        }
        $Output.add($Property)
    }
}

$CurrentDate = (Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')
$Output | Export-Csv "C:\Output\$CurrentDate _TeamsReport.csv" -NoTypeInformation


----------------------------------- End -----------------------------------


No comments:

Post a Comment