Powershell – TEAMS liste accès

o365-logo.jpg

Liste les accès des utilisateurs dans channels de Teams.

Dans ce script, le module Powershell “MicrosoftTeams” a été utilisé. Il s’agit d’une version béta du module (version 1.1.10).

$ExportFile = "c:\temp\TeamsAccess_$(get-date -Format 'yyyyMMddHHmmss').csv"

Import-Module -Name MicrosoftTeams
Connect-MicrosoftTeams

$res = @()

$lstTeams = Get-Team

foreach($Team in $lstTeams){

    $lstTeamChannel = Get-TeamChannel -GroupId $Team.GroupId

    foreach($TeamChannel in $lstTeamChannel){

        $lstTeamChannelUsers = Get-TeamChannelUser -GroupId $Team.GroupId -DisplayName $TeamChannel.DisplayName

        foreach($TeamChannelUsers in $lstTeamChannelUsers){

        $DataCollect = New-Object System.object
        $DataCollect | Add-Member -name ‘TeamName’ -MemberType NoteProperty -Value $Team.DisplayName
        #$DataCollect | Add-Member -name ‘TeamGroupId’ -MemberType NoteProperty -Value $Team.GroupId
        $DataCollect | Add-Member -name ‘ChannelDisplayName’ -MemberType NoteProperty -Value $TeamChannel.DisplayName
        $DataCollect | Add-Member -name ‘UserMailbox’ -MemberType NoteProperty -Value $TeamChannelUsers.user
        $DataCollect | Add-Member -name ‘UserName’ -MemberType NoteProperty -Value $TeamChannelUsers.name
        $DataCollect | Add-Member -name ‘UserRole’ -MemberType NoteProperty -Value $TeamChannelUsers.role

        $Res+=$DataCollect

        }
    }
}

$Res | FT
$Res | Export-Csv $ExportFile -Encoding UTF8 -Delimiter ";" -NoTypeInformation

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *