Bienvenue à Blogs CodeS-SourceS Identification | Inscription | Aide

Blog Technique de Romelard Fabrice

Les dernières Actualités de Romelard Fabrice (Alias fabrice69 ou F___) principalement autour des technologies Microsoft

Actualités

  • Toutes les actualités et informations sur les technologies Microsoft principalement autour de .NET et SQL Server

Archives

Office 365: Script PowerShell pour auditer l’usage de Microsoft Teams de votre tenant

Après les précédents scripts publiés pour auditer votre tenant Office 365:

Il faut maintenant fournir les informations d’usage de Microsoft Teams, c’est ce que fait ce script.


Import-Module MSOnline
Import-Module MicrosoftTeams

[string]$ReportPath = ".\Reports\"
[string]$username = "Admin@yourtenant.onmicrosoft.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

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $session

#Connect-MicrosoftTeams -Credential $cred
Connect-MicrosoftTeams

[int]$i = 1;
$data = @()
[string]$ListOfChannelNames = ""
[string]$TeamOwnersEmails = ""
[string]$TeamMembersEmails = ""
[string]$TeamGuestsEmails = ""

$ListOfTeams = Get-Team  -user $username #Test command to focus
#$ListOfTeams = Get-Team

Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor Magenta


foreach($MyTeams in $ListOfTeams)
{
    Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green

    $TeamUnifiedGroup = Get-UnifiedGroup -Identity $MyTeams.GroupId
    Write-Host "    ===-> Teams GroupID:", $MyTeams.GroupId, "- Name:", $MyTeams.DisplayName, "- Description:", $MyTeams.Description  -ForegroundColor Yellow
    Write-Host "    ===-> GroupEmail:", $TeamUnifiedGroup.PrimarySmtpAddress

    # Current Teams Configuration implemented
    Write-Host "    ===-> Get-TeamMemberSettings:" -ForegroundColor Yellow
    $TeamMemberSettings = Get-TeamMemberSettings -GroupId $MyTeams.GroupId
    Write-Host "          ====> ", $TeamMemberSettings.AllowCreateUpdateChannels

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

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

    Write-Host "    ===-> Get-TeamFunSettings:" -ForegroundColor Yellow
    $TeamFunSettings = Get-TeamFunSettings -GroupId $MyTeams.GroupId
    Write-Host "          ====> ", $TeamFunSettings.AllowGiphy

    $ListOfChannelNames = ""
    $TeamOwnersEmails = ""
    $TeamMembersEmails = ""
    $TeamGuestsEmails = ""
    $CurrentListOfChannelList = Get-TeamChannel -GroupId $MyTeams.GroupId
    foreach($MyChannel in $CurrentListOfChannelList)
     {
        Write-host "      ------------------ " -ForegroundColor green
        Write-Host "      ===-> Channel Name:", $MyChannel.Id, "- Name:", $MyChannel.DisplayName, "- Description:", $MyChannel.Description  -ForegroundColor Magenta
        $ListOfChannelNames += " -|- "+ $MyChannel.DisplayName
    }

    $TeamUsers = Get-TeamUser -GroupId $MyTeams.GroupId
    Write-Host "    ===-> Get-TeamUser:", $TeamUsers.Count -ForegroundColor Yellow
    if ([array]$MyTeamGuest = $TeamUsers | Where {$_.Role -eq "guest"})
    {
        $TeamGuestsCount = $MyTeamGuest.Count
         $MyTeamGuest.ForEach({ $TeamGuestsEmails += "|"+ $_.User  })
        Write-Host "       ===-> TeamGuestsEmails:", $TeamGuestsEmails -ForegroundColor Magenta
    }
    else
    {
        $TeamGuestsCount = 0
        $TeamGuestsEmails = ""
    }

    if ([array]$MyTeamMembers = $TeamUsers | Where {$_.Role -eq "member"})
    {
        $TeamMembersCount = $MyTeamMembers.Count
         $MyTeamMembers.ForEach({ $TeamMembersEmails += "|"+ $_.User  })
        Write-Host "       ===-> TeamMembersEmails:", $TeamMembersEmails -ForegroundColor Magenta
    }
    else
    {
        $TeamMembersCount = 0
        $TeamMembersEmails = ""
    }

    if ([array]$MyTeamOwners = $TeamUsers | Where {$_.Role -eq "owner"})
    {
        $TeamOwnersCount = $MyTeamOwners.Count
         $MyTeamOwners.Foreach({ $TeamOwnersEmails += "|"+ $_.User  })
        Write-Host "       ===-> TeamOwnersEmails:", $TeamOwnersEmails -ForegroundColor Magenta
    }
    else
    {
        $TeamOwnersCount = 0
        $TeamOwnersEmails = ""
    }

#Team name    TeamMail    Channels    MembersCount    OwnersCount    GuestsCount    Privacy

    $data += @(
        [pscustomobject]@{
         GroupID = $MyTeams.GroupId
        GroupTeamMail = $TeamUnifiedGroup.PrimarySmtpAddress
        GroupHiddenfromOutlook = $TeamUnifiedGroup.HiddenFromExchangeClientsEnabled
        GroupAccessType = $TeamUnifiedGroup.AccessType
        GroupExternalMemberCount = $TeamUnifiedGroup.GroupExternalMemberCount
        TeamName = $MyTeams.DisplayName
        TeamDescription = $MyTeams.Description
        TeamMemberSettingsAllowCreateUpdateChannels = $TeamMemberSettings.AllowCreateUpdateChannels
        TeamMemberSettingsAllowDeleteChannels = $TeamMemberSettings.AllowDeleteChannels
        TeamMemberSettingsAllowAddRemoveApps = $TeamMemberSettings.AllowAddRemoveApps
        TeamMemberSettingsAllowCreateUpdateRemoveTabs = $TeamMemberSettings.AllowCreateUpdateRemoveTabs
        TeamMemberSettingsAllowCreateUpdateRemoveConnectors = $TeamMemberSettings.AllowCreateUpdateRemoveConnectors
         TeamMessagingSettingsAllowUserEditMessages = $TeamMessagingSettings.AllowUserEditMessages
        TeamMessagingSettingsAllowUserDeleteMessages = $TeamMessagingSettings.AllowUserDeleteMessages
        TeamMessagingSettingsAllowOwnerDeleteMessages = $TeamMessagingSettings.AllowOwnerDeleteMessages
        TeamMessagingSettingsAllowTeamMentions = $TeamMessagingSettings.AllowTeamMentions
        TeamMessagingSettingsAllowChannelMentions = $TeamMessagingSettings.AllowChannelMentions
        TeamGuestSettingsAllowCreateUpdateChannels = $TeamGuestSettings.AllowCreateUpdateChannels
        TeamGuestSettingsAllowDeleteChannels = $TeamGuestSettings.AllowDeleteChannels
        TeamFunSettingsAllowGiphy = $TeamFunSettings.AllowGiphy
        TeamFunSettingsGiphyContentRating = $TeamFunSettings.GiphyContentRating
        TeamFunSettingsAllowStickersAndMemes = $TeamFunSettings.AllowStickersAndMemes
        TeamFunSettingsAllowCustomMemes = $TeamFunSettings.AllowCustomMemes
        TeamChannelsCount = $CurrentListOfChannelList.Count
        TeamChannelsNames = $ListOfChannelNames
         TeamOwnersCount = $TeamOwnersCount
        TeamOwnersEmails = $TeamOwnersEmails
        TeamMembersCount = $TeamMembersCount
        TeamMembersEmails = $TeamMembersEmails
        TeamGuestsCount = $TeamGuestsCount
        TeamGuestsEmails = $TeamGuestsEmails
        }
    )


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

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

$datestring = (get-date).ToString("yyyyMMdd-hhmm")
$fileName = Join-Path -Path $ReportPath  -ChildPath $("O365-TeamsDetails_"+ $datestring + ".csv")
   
Write-host " -----------------------------------------" -ForegroundColor Green
Write-Host (" >>> writing to file {0}" -f $fileName) -ForegroundColor Green
$data | Export-csv $fileName -NoTypeInformation -enc utf8
Write-host " -----------------------------------------" -ForegroundColor Green


Vous pouvez adapter et utiliser ce script selon vos propres besoins.

Romelard Fabrice

Version Anglaise:

Sources utilisées:

Ce post vous a plu ? Ajoutez le dans vos favoris pour ne pas perdre de temps à le retrouver le jour où vous en aurez besoin :
Posted: vendredi 26 avril 2019 10:39 par ROMELARD Fabrice

Commentaires

Pas de commentaires

Les commentaires anonymes sont désactivés

Les 10 derniers blogs postés

- Office 365: Script PowerShell pour auditer l’usage des Office Groups de votre tenant par Blog Technique de Romelard Fabrice le 04-26-2019, 11:02

- Office 365: Script PowerShell pour auditer l’usage de Microsoft Teams de votre tenant par Blog Technique de Romelard Fabrice le 04-26-2019, 10:39

- Office 365: Script PowerShell pour auditer l’usage de OneDrive for Business de votre tenant par Blog Technique de Romelard Fabrice le 04-25-2019, 15:13

- Office 365: Script PowerShell pour auditer l’usage de SharePoint Online de votre tenant par Blog Technique de Romelard Fabrice le 02-27-2019, 13:39

- Office 365: Script PowerShell pour auditer l’usage d’Exchange Online de votre tenant par Blog Technique de Romelard Fabrice le 02-25-2019, 15:07

- Office 365: Script PowerShell pour auditer le contenu de son Office 365 Stream Portal par Blog Technique de Romelard Fabrice le 02-21-2019, 17:56

- Office 365: Script PowerShell pour auditer le contenu de son Office 365 Video Portal par Blog Technique de Romelard Fabrice le 02-18-2019, 18:56

- Office 365: Script PowerShell pour extraire les Audit Log basés sur des filtres fournis par Blog Technique de Romelard Fabrice le 01-28-2019, 16:13

- SharePoint Online: Script PowerShell pour désactiver l’Option IRM des sites SPO non autorisés par Blog Technique de Romelard Fabrice le 12-14-2018, 13:01

- SharePoint Online: Script PowerShell pour supprimer une colonne dans tous les sites d’une collection par Blog Technique de Romelard Fabrice le 11-27-2018, 18:01