Managing Teams with PowerShell
If your familiar with my writing, you know I'm a huge proponent of Office 365 administrators...
Hello from the bunker! I assume most of you will be reading this blog post from my future, and hopefully the world has returned to something closer to “normal”. By normal, I mean there isn’t a pandemic going on and people can leave their houses. As I write this blog post, I am about a month into the COVID-19 pandemic of 2020 and I haven’t left my house except for trips to the grocery store for what feels like about 20 years.
Regardless of if you’re reading this from your own social distancing hide out, or if you’re back in the office working like you did in 2019, it’s time for organizations to put more effort into their remote worker management. I do think that a lot more people are going to be doing a lot more remote work in the very near future. With more users working remotely, we as IT pros need to focus more on reporting data around our services usage and helping management understand how IT resources are being used.
As I see it, Office 365 and Teams specifically are going to be a big part of the remote workforce in the future. This means that we, as IT pros, need to understand how Teams is being used.
In this blog post, I’m going to go though some tips and tricks for digging into the data your Office 365 tenant is collecting on Teams usage with PowerShell. Think of this blog post as a starting point for learning how to gather information about the Teams deployed in your tenant.
The first thing I think most admins would be interested in learning is what Teams are setup and being used within their environment. Seems like this should be a straightforward bit of information to find via PowerShell, right?
Yes and no. If you connect to Teams PowerShell, you’ll find the command Get-Team. This is the place to start, but you’ll quickly find there really isn’t much information available via this cmdlet. Below is a screenshot of the output from my tenant.
The only information returned from Get-Team is a list of the Group IDs for each Team, the Team Display Name, and the Team Description. That’s it.
Teams isn’t just “Teams”, but a combination of several Office 365 services wrapped into one interface. This means that gathering information about your Teams will require more than just Teams PowerShell commands.
The first thing you’ll need to do is connect your PowerShell session to Exchange Online, SharePoint Online, Skype for Business Online, and Teams for your Office 365 tenant. I do this with the Connect-365 script from Chris Goosen (MVP).
Once that is done, your PowerShell sessions should look like this.
Once connected, you can run my script (we’ll get into the script in a minute) and you’ll get something that looks like this.
Now you can really see some useful information about the Teams in your tenant!
As I said above, the information you want about the Teams in your tenant is not all stored in “Teams”, but in several other different services in Office 365. Since this is the case, the best way to pull all that information into one place is PowerShell!
Here is the script I put together to pull that information
$Output = @() $Teams = Get-Team
ForEach ($Team in $Teams) { $ $TeamUsers = Get-TeamUser -GroupId $Team.GroupId
$UnifiedGroup = Get-UnifiedGroup -Identity $Team.GroupId $SPOSite = Get-SPOSite -Identity $UnifiedGroup.SharePointSiteUrl $FolderStatistics = Get-MailboxFolderStatistics -Identity $UnifiedGroup.Identity | Where {$_.FolderPath -eq "/Conversation History/Team Chat"}
$Result = New-Object Object $Result | Add-Member DisplayName $Team.DisplayName $Result | Add-Member Description $Team.Description $Result | Add-Member Classification $UnifiedGroup.Classification $Result | Add-Member EmailAddress $UnifiedGroup.PrimarySmtpAddress $Result | Add-Member MemberCount $UnifiedGroup.GroupMemberCount $Result | Add-Member GuestCount $UnifiedGroup.GroupExternalMemberCount $Result | Add-Member HiddenfromOutlook $UnifiedGroup.HiddenFromExchangeClientsEnabled $Result | Add-Member StorageUsedMB $SPOSite.StorageUsageCurrent $Result | Add-Member TeamChatsinMBX $FolderStatistics.ItemsInFolder
$Output+=$Result }
$Output
As you can see from the script, it pulls information from Teams, Unified Groups, SharePoint and Exchange and builds you a single output that shows information you could not get in once place otherwise. Because Teams is truly a cloud only service built on top of multiple different Office 365 services, we do have to work a little harder to gather a complete picture of the Teams usage within our Office 365 tenants.
Of course, this script doesn’t pull every bit of information available about Teams. I made a few choices about what information to include, but maybe you’re looking for something different. If that’s the case, let us know in the comments and I’ll see what I can do about modifying the script. Once I get a more mature version of this script built out, I’ll publish it to my GitHub.
ENow's Office 365 solution has a wide variety of built in Office 365 reports ranging from: traffic, storage & usage, client access, app specific reports (Teams, OneDrive, etc), license adoption, license management, and more! These reports can easily be customized to meet your organizations needs.
Given the breadth of Office 365 and each organizations unique reporting needs, we realize it would be nearly impossible to make every report imaginable out of the box. With that said, we have built in PowerShell component with the ability to store your own reports directly to the console.
Nathan is a five time former Microsoft MVP and he specializes in Exchange, Microsoft 365, Active Directory, and cloud identity and security.
If your familiar with my writing, you know I'm a huge proponent of Office 365 administrators...