こんにちは、Teamsサポートの吉野です。
本日は便利なスクリプトを紹介させていただきます。
「現在作成されているチームの一覧を取得したい」という要望があるかと思います。
実はこちら、標準の機能では実装しておりません。
例えば管理者権限で Get-Team を実行してもそのユーザーが所属しているチームの一覧しか取得できません。
テナント全体のチーム一覧は以下のようなスクリプトで取得する必要があります。
Microsoft Teams Enabled O365 Groups Report PowerShell CSV Output
こちら大変便利なのですが、試してみたところ日本語が文字化けすることが分かりました。
日本語対応してみましたのでご活用いただければと思います。
## Microsoft Teams O365 Group Enabled Teams Reporting Script ## Created and edited by Sam Cosby - Microsoft & David Whitney - Microsoft ## 2/2/2018 ## Require PowerShell Admin If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Warning "`nYou do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!" Break } ## Connect to EXO $shell = new-object -comobject "WScript.Shell" $result = $shell.popup("Do your Admin Credentials require MFA?",0,"Question",4+32) if ($result -eq "6") { Write-Host "You must connect via the Exchange Online MFA Powershell module. To learn more on this, please use the following: https://technet.microsoft.com/en-us/library/mt775114(v=exchg.160).aspx" break; } if (-not (Get-PSSession | where {($_.ComputerName -eq "outlook.office365.com") -and ($_.State -eq "Opened")})) { Write-Output "####################################################### Please connect with your Exchange Online Administrator Credentials in order to finish the rest of the script. ####################################################### " $cred = get-credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue Import-PSSession $Session -WarningAction SilentlyContinue } ## Connect to Microsoft Teams if (Get-Module | where {($_.Name -eq "MicrosoftTeams") -and (($_.Version -eq "0.9.1") -or ($_.Version -eq "0.9.0"))}) {"Teams PowerShell is connected"} elseif (Connect-MicrosoftTeams -Credential $cred){"Teams Powershell needs connected"} else {Write-Output "You need to install the Microsoft Teams module. To do so, input 'install-module MicrosoftTeams' in Powershell as an Administrator"} ## Run the script to gather the list of Teams. clear Write-Output "####################################################### This may take a little bit of time... Please sit back, relax and enjoy some GIFs inside of Teams! d8b .d888888 Y8P d88P 888 888 888 88888b.d88b. 888 .d8888b888d888. d88b. .d8888b .d88b. 888888888888 888 888 88b888d88P 888P d88 88b88K d88 88b888 888 888 888 888888888 888 888 888 Y8888b.888 888888 888 888 888 888888Y88b. 888 Y88..88P X88Y88..88P888 Y88b. 888 888 888888 Y8888P888 Y88P 88888P' Y88P 888 Y888 ####################################################### " $o365groups = Get-UnifiedGroup -ResultSize Unlimited $TeamsList = @() foreach ($o365group in $o365groups) { try { $teamschannels = Get-TeamChannel -GroupId $o365group.ExternalDirectoryObjectId $o365GroupMemberList = (Get-UnifiedGroupLinks -identity $o365group.ExternalDirectoryObjectId -LinkType Members) | select -expandproperty PrimarySmtpAddress $TeamsList = $TeamsList + [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; SMTP = $o365group.PrimarySmtpAddress; Members = $o365group.GroupMemberCount; MemberList = $o365GroupMemberList -join ', '; SPOSite = $o365group.SharePointSiteUrl; TeamsEnabled = $true; Owners = $o365group.ManagedBy} } catch { $ErrorCode = $_.Exception.ErrorCode switch ($ErrorCode) { "404" { $TeamsList = $TeamsList + [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; SMTP = $o365group.PrimarySmtpAddress; Members = $o365group.GroupMemberCount; MemberList = $o365GroupMemberList -join ', '; SPOSite = $o365group.SharePointSiteUrl; TeamsEnabled = $false; Owners = $o365group.ManagedBy} break; } "403" { $TeamsList = $TeamsList + [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; SMTP = $o365group.PrimarySmtpAddress; Members = $o365group.GroupMemberCount; MemberList = $o365GroupMemberList-join ', '; SPOSite = $o365group.SharePointSiteUrl; TeamsEnabled = $true; Owners = $o365group.ManagedBy} break; } default { Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $o365group, $ErrorCode) } } } } New-Item -ItemType directory -Path c:Teams $TeamsList | export-csv C:TeamsAllTeamsInTenant.csv -NoTypeInformation -Encoding UTF8 clear Write-Output "####################################################### CSV files exported to c:TeamsTeamsAllTeamsInTenant.csv, filter by the TeamsEnabled tab to validate which Groups are Teams Enabled. Thank you for choosing Microsoft Teams! ####################################################### "