The estimated reading time 4 minutes
UPDATE 29/03/2020: this article works, but now Teams Module was relaunched and can do quite more things. See my later article: https://blog.it-koehler.com/en/Archive/2074
NOTE: the following actions ONLY shows team groups created in teams, NO converted O365 groups are shown.
For HTML Reports have a look in comments!
$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") }
Because a lot of objects returned after running, I chose a “select” for filtering.
$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") } | Select-Object DisplayName,Alias,ProvisioningOption,SharePointSiteUrl,SharePointDocumentsUrl,AccessType,Language,ExchangeGuid,ManagedBy)
Thus, all O365 groups created by the team users can be displayed.
Not bad at all.
Now I also want to get the group members displayed.
Get-UnifiedGroupLinks -Identityid
-LinkType Members
As far as not very difficult.
So bringing these two steps together is not as easy as it looks like.
For this I have built the following Powershell script.
<# .SYNOPSIS script for showing all office 365 groups created by microsoft teams .DESCRIPTION .EXAMPLE no parameters needed .Notes connect to exchange online first https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx or see https://blog.it-koehler.com/en/Archive/1589 --------------------------------------------------------------------------------- Script: get-allteams-withmembers-0-1.ps1 Author: A. Koehler; blog.it-koehler.com ModifyDate: 18/03/2018 Usage: identify all teams groups in office 365 and get members Version: 0.1 --------------------------------------------------------------------------------- #> #get all groups created with ms teams (filtered ExchangeProvisioningFlag:481) #raw powershell command: Get-UnifiedGroup | Where-Object {$_.ProvisioningOption -eq "ExchangeProvisioningFlags:481" } | fl $teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") } | Select-Object DisplayName,Alias,ProvisioningOption,SharePointSiteUrl,SharePointDocumentsUrl,AccessType,Language,ExchangeGuid,ManagedBy) #notification for powershell Write-Host "Getting Office 365 Groups created with MS Teams... " -ForegroundColor Green #generate array for teamsgroups $teams = @() #loop to get information ForEach ($group in $teamsgroups){ #get-members of group $identity = (($group).ExchangeGuid) $members = (Get-UnifiedGroupLinks -Identity "$identity" -LinkType Members | Select-Object PrimarySMTPAddress) $owners = (Get-UnifiedGroupLinks -Identity "$identity" -LinkType Owners | Select-Object PrimarySMTPAddress) $member = (($members).primarySMTPAddress) | Out-String -Width 4096 $owner = (($owners).primarySMTPAddress) | Out-String # Adding pscustomobjets entries to array $teams += [pscustomobject]@{ DisplayName = ($group).DisplayName Alias = ($group).Alias AccessType = ($group).AccessType Language = ($group).Language Members = ("$member") Owner = ("$owner") } } #out put in GridView (external window) Write-Host "Display in Grid View Window " -ForegroundColor Green $teams | Out-GridView -Title "All Office365 Groups created in MS Teams" #out put in powershell #$teams | Format-Table -AutoSize -Wrap #erase content of variables $teams =$null $member = $null
This reads all groups with members and also the current manager / owner. We have an overview of the current teams groups within the company.
Criticism and feedback is welcome.
Have fun testing.
this is really great and exactly what I was looking for, what about exporting this to excel?
hi brandon,
I’ll try that and give a short feedback. Have a look at dfinke importexport excel module
https://github.com/dfinke/ImportExcel
Just give me some time.
best regards
Hi Brandon,
I found some time to check your question.
Yes with the module of dfinke it is quite easy. Start the powershell and install the module with the following powershell command:
Install-Module ImportExcel -scope CurrentUser -Verbose -Force
Import-Module ImportExcel -Verbose
After this action you can add the following line:
$teams | Out-GridView -Title "All Office365 Groups created in MS Teams"
$teams | Export-Excel
I checked the script and wondered why it does not give me some groups. May there was a change in O365 and the teams filter does not work in my script.
So I also updated the script
with the following line:
$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") } | Select-Object DisplayName,Alias,ProvisioningOption,SharePointSiteUrl,SharePointDocumentsUrl,AccessType,Language,ExchangeGuid,ManagedBy)
Please tell me if it does the trick.
Have fun.
Is there anyway to add Created date and when changed date to this script for each team?
At the moment I’m working on a new version of the script which will also include the dates.
this does not account for teams that were created from o365 groups that already existed. seeing that you are only looking for the provisionflag 481, those are groups created from teams. but what about an exchange group that later is converted to a team? is there anything you can think of that could distinguish those? I have a problem when doing a get-unifiedgroup and then trying to sort. if I sort by just the 481 provision flag 368 out of 576 are recognized. I am confident to say those are teams. but I also know from tests I have done I have more teams that that. be it the group started as just an 0365 group, or yammer group or power bi group.
I gave a try to filter all teams but you’re right. After converting a office 365 group into a team this flag is not set, so script gives no attention to this. After some time spending for research there are some threads dealing with the same issue.
https://techcommunity.microsoft.com/t5/Microsoft-Teams/Show-a-list-of-all-teams-and-owners/td-p/30526
So no solution yet. After some more time I got the following articel
https://techcommunity.microsoft.com/t5/Microsoft-Teams/Teams-enabled-O365-Groups-report-workaround-in-PowerShell/td-p/141029
This can do the trick.