Generating and Emailing a Teams Creation Report

Office 365 Audit Records Useful Source of Information

Recently another MVP pointed out that Office 365 Activity Alerts don’t seem to work so well. At least, he tried to set one up to alert him when someone created a new team and no alert was ever sounded.

Activity alerts depend on events logged in the Office 365 audit log. I tried to create an activity alert for new team creations and Office 365 remained mute for several days. In fact, I haven’t seen an activity alert for team creation yet. Something odd is happening on the back end because the events are in the audit log.

Script for DIY Emailed Report

In any case, I decided to roll my own activity alert by running the Search-UnifiedAuditLog cmdlet to find team creation events, parsing the AuditData content, and emailing the resulting information. Because I don’t like recreating the wheel, I combined code from Chapter 21 of the Office 365 for IT Pros eBook to parse the results returned from Search-UnifiedAuditLog and some code from one of my articles to format and send the message.

The original script appeared on 30 July 2019. This is version 2 of the code and it adds some information to the emailed report such as the privacy setting for the team, its classification, the number of group members, and the number of guests. You’ll also note that I sort the audit records by team name to get one record for each team. Sometimes Office 365 creates multiple audit records when a new team is created. Remember to update the $EmailRecipient variable with a valid email address before you run the script.

Figure 1 shows what the resulting email looks like:

The Teams Creation Report as emailed
Figure 1: The Teams Creation Report as emailed

Feel free to amend the script to meet your own requirements. Don’t forget to tell us about all the great improvements you make by posting comments here.

5 Replies to “Generating and Emailing a Teams Creation Report”

  1. Thanks for the information. It worked really fine! I did some ammends, to report if the Teams is public or private (requested by management), but it saved a lot of time.

  2. Thanks for the idea David… I have refreshed the script to add more team properties to the creation report.

  3. I’m getting an error Method invocation failed because [System.Collections.Generic.List`1[ does not contain a method named ‘new’. Any idea why?

    1. At this line?

      $Report = [System.Collections.Generic.List[Object]]::new()

      That’s a basic PowerShell command. It should work without any problems.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.