Office 365 Groups and Teams Activity Report

A PowerShell script to report on the Office 365 Groups and Teams in a tenant by checking their activity across Outlook conversations, Teams chat, and SharePoint document activity.

 
 
 
 
 
4.9 Star
(7)
9,242 times
Add to favorites
Office 365
4/30/2020
E-mail Twitter del.icio.us Digg Facebook
  • This script is fantastic. How can I get the history of meetings held by the team and the number of meetings held?
    2 Posts | Last post March 12, 2020
    • This script is fantastic. How can I get the history of meetings held by the team and the number of meetings held?
    • That data isn't easily accessible from PowerShell (if at all), so it can't be included in this script.
  • SPOSiteUrl
    2 Posts | Last post February 29, 2020
    • How would I amend this so a SPOSiteURL column is also included in the report?
    • The site URL is a big (wide) column to add, but it's easy to include by adding
      
      SiteURL = $G.SharePointDocumentsUrl
      
      in the set of properties written into the $Reportline variable for each group.
  • TeamEnabled is always False
    3 Posts | Last post February 28, 2020
    • Even though I know there is Teams associated with the site collection. is there an issue?
    • I see the issue. Get-Team fail in my Tenant. This worked though. https://techcommunity.microsoft.com/t5/microsoft-teams/teams-enabled-o365-groups-report-workaround-in-powershell/m-p/141029
      
      $o365groups = Get-UnifiedGroup
      foreach ($o365group in $o365groups) {
          try {
              $teamschannels = Get-TeamChannel -GroupId $o365group.ExternalDirectoryObjectId
              [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $true}
          } catch {
              $ErrorCode = $_.Exception.ErrorCode
              switch ($ErrorCode) {
                  "404" {
                      [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $false}
                      break;
                  }
                  "403" {
                      [pscustomobject]@{GroupId = $o365group.ExternalDirectoryObjectId; GroupName = $o365group.DisplayName; TeamsEnabled = $true}
                      break;
                  }
                  default {
                      Write-Error ("Unknown ErrorCode trying to 'Get-TeamChannel -GroupId {0}' :: {1}" -f $o365group, $ErrorCode)
                  }
              }
          }
      }
    • That code was written as a workaround because Get-Team originally couldn't return all the teams in a tenant. I wouldn't use it. Instead, I'd focus on why Get-Team isn't working for you. Do you have admin permissions (and a license for Teams)? What happens when you run Get-Team interactively?  Fix that problem and you'll be all set.
  • You cannot call a method on a null-valued expression?
    2 Posts | Last post February 22, 2020
    • Logged in as Admin on Powershell and logged into teams and exchange through the same session. The script runs and I get the summary but not the detailed report. Instead, I am getting this:
      
      You cannot call a method on a null-valued expression.
      At C:\scripts\TeamsGroupsActivityReport.ps1:178 char:4
      +    $Report.Add($ReportLine)
      +    ~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
    • Sounds like no groups are being processed. Are you sure that you have the necessary admin permissions to access Groups from PowerShell?
  • Difference between LastChat and LastConversation
    2 Posts | Last post February 21, 2020
    • Hi team,
      
      I'm confused between LastChat and LastConversation data. What's the definition of these columns ? 
      
      
    • LastChat is the last message posted to a channel conversation in a team (if a Group is team-enabled).
      
      LastConversation is the last message posted to the Inbox for a conversation in a group (Outlook groups).
  • Permissions to the PS1 script
    2 Posts | Last post February 21, 2020
    • Hello,
      Basic question -- I am tenant SharePoint Online Admin but not an o365 tenant admin.
      I have access to the Teams Admin Centre.
      
      I can run PowerShell via Windows ISE and can connect to SharePoint Online Admin.
      
      Do I have the right permissions to run this Script?
      Thanks
      Cliff
    • No. You'll need to connect to Exchange Online too.
  • Changes to Conversation settings
    2 Posts | Last post January 15, 2020
    • It looks like conversations are stored somewhere other than in the mailbox now. When I run the script it states that there is only one conversation in almost ALL of my teams, even the teams where I know multiple conversations have happened.
      
      It looks like it marks all of these conversations as chats now, so maybe something to change in the script.
    • Thanks for the heads-up. When I originally wrote the script, the Conversation History folder tended to have two subfolders in it, one of which contained the compliance records for Teams. However, as Skype for Business Online is phased out, it seems like there might only be one folder in user mailboxes. I've changed the code to look for the TeamChat folder explicitly using the folder type. Give Version 4.1 a whirl!
  • Performance improvement using session
    5 Posts | Last post January 11, 2020
    • Would it be helpful to change the EXO commands to the following to improve performance for larger tenants:
      
      $Cred = Get-Credential -Message "Please enter Exchange Online admin email address and password"
      $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Authentication Basic -AllowRedirection -Credential $Cred
      ...
      (Invoke-Command -Session $Session -ScriptBlock { Get-OrganizationConfig | Select-Object Name } -ErrorAction Stop).Name
      ...
      $Groups = Invoke-Command -Session $Session -scriptblock { Get-UnifiedGroup -ResultSize Unlimited | select-object -property DisplayName,DistinguishedName,GroupMemberCount,GroupExternalMemberCount,Notes,SharePointDocumentsUrl,ExternalDirectoryObjectId,ManagedBy,Alias } | Sort-Object DisplayName
      ...
      $ManagedBy = (Invoke-Command -Session $Session -ScriptBlock { Get-Mailbox -Identity $using:G.ManagedBy[0].DistinguishedName | Select-Object DisplayName }).DisplayName
      ...
      $Data = (Invoke-Command -Session $Session -ScriptBlock { Get-MailboxFolderStatistics -Identity $using:G.Alias -IncludeOldestAndNewestITems -FolderScope Inbox | Select-Object NewestItemReceivedDate,ItemsInFolder})
      ...
      $AuditRecs = (Invoke-Command -Session $Session -ScriptBlock { Search-UnifiedAuditLog -RecordType SharePointFileOperation -StartDate $using:WarningDate -EndDate $using:Today -ObjectId $using:AuditCheck -SessionCommand ReturnNextPreviewPage -ResultSize 1 })
      ...
      $TeamChatData = (Invoke-Command -Session $Session -ScriptBlock { Get-MailboxFolderStatistics -Identity $using:G.Alias -IncludeOldestAndNewestItems -FolderScope ConversationHistory | Select-Object NewestItemReceivedDate,ItemsInFolder })
    • Hi Brendan,
      Sorry for my ignorance, but where would those lines go in Tony's script? Or are they ran before you run the script?
      Thanks in advance.
    • when inserting your script I get an error like below:
      
      Cannot process argument transformation on parameter 'Identity'. Cannot convert value "last, firstname" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". Error: "Cannot convert the "last, firstname" value of 
      type "Deserialized.Microsoft.Exchange.Data.Directory.ADObjectId" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter"."
          + CategoryInfo          : InvalidData: (:) [Get-Mailbox], ParameterBindin...mationException
          + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Mailbox
          + PSComputerName        : outlook.office365.com
    • It usually comes after "Team name only 2 conversation item(s) found.".
    • Yes, you could do that to improve performance. You could also use Get-Recipient to return a list of Office 365 Groups faster. I have a rewrite on my to do list.
      
      TR
  • will this work if user office 365 group is planner or power BI?
    2 Posts | Last post January 11, 2020
    • We are trying to cleanup and there are some office 365 groups which has Microsoft Planner or PowerBI Dashboard. Is there a way we can extend this script to check that as well. 
    • You could write some Graph code to find out about Planner activity. I suspect this will become easier when Microsoft launches its new Task apps in the near future. I don't know about Power BI.
  • Getting error
    2 Posts | Last post July 05, 2019
    • I keep getting this error:
      
      Get-SPOSite : The managed path sites/SITE is not a managed path in this tenant.
      At C:\...\TeamsGroupsActivityReport_v2.ps1:124 char:19
      + ... $SPOSite = (Get-SPOSite -Identity $G.SharePointDocumentsUrl.replace(" ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Get-SPOSite], ServerException
          + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.GetSi
         te
    • this scripts works only in english tenant.
      Use this code to remove the document library from the url.
      
      $pos = $G.SharePointDocumentsUrl.LastIndexOf('/')
      $SharePointDocumentsUrl = $G.SharePointDocumentsUrl.Substring(0, $pos)
      Write-Host	$SharePointDocumentsUrl
      $SPOSite = (Get-SPOSite -Identity $SharePointDocumentsUrl)
      
1 - 10 of 21 Items