Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Microsoft Teams|Office|Office 365

Revisiting the Office 365 Groups and Teams Activity Report

Office 365 with Teams

A Year On, Time to Revise

In January 2018, I published “Finding Obsolete Office 365 Groups with PowerShell,” describing a script to analyze the Office 365 Groups in a tenant and report on whether some of the groups might be obsolete because they aren’t used. The script is available in the TechNet gallery for anyone who wants to download a copy.

A year or so later, it was time to look at the script and improve it. Teams is more important now and we have a rapidly changing Teams PowerShell module, so the kludge used to detect if an Office 365 group is team-enabled is no longer necessary. In fact, there’s several ways to check.

Checking for Teams

I could have depended on the setting Teams uses to hide its groups from Exchange clients and used a command like the one below to find these groups:

Get-UnifiedGroup | ? {$_.HiddenFromExchangeClientsEnabled -eq $True}

The problem is that the command uses a client-side filter so it’s slow. Because it checks so many aspects of a group, the Get-UnifiedGroup cmdlet is already slow, so adding an extra layer of slowness isn’t a good thing. But a more fundamental problem is that Teams only started to hide its groups from April 2018 and any early team-enabled group does not have this setting. In my tenant, roughly a third of the team-enabled groups were marked.

Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.

Another idea is to use the external directory object identifier returned for each group with a command like Get-TeamChannel to test whether any channels exist for that identifier. Code like this would work.

If (Get-TeamChannel -GroupId (Get-UnifiedGroup -id "Office 365 for it pros").ExternalDirectoryObjectId)      
    { Write-Host "Some Channels Exist"}

Checking for the presence of channels works, but again might be slow when a tenant supports hundreds or thousands of teams.

In the end, I chose to use the Get-Team cmdlet to fetch a list of teams and load them into an array. Get-Team is a very simple cmdlet and runs very quickly. All I loaded into the array was the identifier for each team. I could then check the identifier fetched for a group against the array to quickly discover if the group is team-enabled.

Upgrades and Progress

Apart from upgrading the script to deal more elegantly with Teams, I made several changes to improve the code, like dealing with groups with no owners more precisely. Some better checking is now done against the compliance records logged for Teams in the Team Chat folder to figure out whether the team is active.

Updates like the ability to deal with site designs appeared in the SharePoint PowerShell module during 2018, but nothing came along to help me figure out the level of activity within a site, so much the same code is used for that.

On an aesthetic note, the script now displays a progress bar (Figure 1) to tell you how many of the available groups have been processed.

Figure 1: Progressing through groups and teams (image credit: Tony Redmond)

The script now generates a CSV file as well as a HTML report. Creating a CSV file from the gathered data is an easy one-line addition that delivers a lot of value. It’s often easier to analyze information about a large set of items through Excel (Figure 2), or if you prefer, by loading the CSV data into Power BI.

Figure 2: The CSV file with group activity data (image credit: Tony Redmond)

More Improvements?

As I pointed out in the original article, I am not a professional programmer. The PowerShell that I produce is the result of hours of happy hacking and it’s ripe for improvement by people who know better. I look forward to seeing what the PowerShell pros can do. In the meantime, I’ll keep on my path of incremental improvement.


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

Tony Redmond has written thousands of articles about Microsoft technology since 1996. He covers Office 365 and associated technologies for and is also the lead author for the Office 365 for IT Pros eBook, updated monthly to keep pace with change in the cloud.
Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: