List app usage in Microsoft Teams
A couple of weeks ago I saw a thread in the interwebs where someone asked about information on Teams app usage. The question was what apps are used in which teams. I knew from experience with the Office365 CLI and the Teams commands there, that this should be possible to accomplish with the existing commands. So here we go.
ListAllTeamsApps.ps1
The first tiny script just iterates through all your teams and lists all apps in each team. Remember: the command will list only those teams you have access to. You can start this with your personal account, but to get all teams you will need an admin account to run those lines.
Lines 7 to 11 should warn our users that the operation they started will probably take some time to finish. We iterate through all teams and make a second Graph call to every team. I’m roughly calculating a second for each of those calls, might depend on your connection. But I like to warn users and admins that some scripts just take their time.
CountAllTeamsApps.ps1
The second script takes the same approach but instead of creating just a list of all the apps in each team, we want to count the usage of every app. The output is not really spectacular in the shell.
But if you copy that output to a text editor of choice and from there to Excel and click on “Text to columns” in the “Data” tab you can separate the display name from the value. Mark all entries and select your chart of choice.
Back to the script. It’s again nothing fancy. We are getting all teams from the Graph through the o365 teams team list command form Office365 CLI. Again we warn our users if they start a potential long-running operation. We then iterate through each team and start counting the app usage. Finally, we output our calculations to our users. We are using Write-Ouput in both scripts on purpose to allow users to redirect the output to other commands or to a file. Of course, the duration warning will be shown directly on the screen.
Summary
Both scripts didn’t take a long time to write. I think I spent one evening playing with both of them. My test tenant has 292 teams so running the script in real time already tool quite some time.
Interesting found: it looks like the PowerBi App is installed twice in each and every team. Not sure if that’s a problem with my tenant or my script, will need to test this on other tenants first.
What is really cool is, that we are standing on the shoulders of giants here. If you go through each line of both scripts you realize that the magic actually happens in the Office365 CLI and not in my scripts. By reusing the commands the community created we can build those small helpers super easy and add them to our own toolbelt. If you miss a certain command in the CLI, the fine people of the team are always looking for new ideas to make the tool better. But remember, it’s an open-source community effort, everyone also has a daytime job. Be kind and you will find help there.
PS: Thx Appie for pushing me over the last couple of days. Only a couple of more blog posts in draft pending ;)