1 min to read
Getting Inactive Office365 groups
In the previous blog we have learned how to restrict the permission of creating new Office365 Groups to a specific security group. There are scenarios where lot of office365 groups created and there are no conversations in those Office365 Groups.
In this blog we are going to check how to retrieve the inactive Office365 Groups.
We are going to use the following PowerShell cmdlets
- Get-UnifiedGroup - Retrieves the Office365 Groups
- Get-MessageTrace - Retrieves all the messages passed through your Office365 service
Steps involved to achieve this
- Get all the Office365 Groups
- Get all the messages passed through your Office365 service for last ‘N’ days. Here ‘N’ denotes the number of inactive days.
- Now check what are the Office365 Group’s addresses that are not found in the message trace. These are the inactive Office365 Groups.
Powershell script
$InactiveDays = 30 //replace with required days
$Groups= Get-UnifiedGroup
$messages = Get-MessageTrace -startdate ([system.DateTime]::Now.AddDays(-$InactiveDays)) -enddate ([system.DateTime]::Now.AddDays(+1)) |where-object{$_.Status -like "Expanded" -or $_.Status -like "Delivered"}
$Groups | Foreach-Object{
$Group = $_
$LastTime = $messages | where-object{$_.RecipientAddress -Like $Group.PrimarySmtpAddress}
If($LastTime.Received -eq $null)
{
New-Object -TypeName PSObject -Property @{
Groupname=$Group.DisplayName
GroupType=$group.GroupType
EmailAddress=$group.PrimarySmtpAddress
}}}|select Groupname,GroupType,EmailAddress
Performance with message tracing
The look back period for message tracing data is 90 days. And also when you query for message trace less than 7 days, it will take 5-30 minutes and for more than 7 days , the result will take few hours. Said this limitation you can retrieve the inactive Office365 Groups for 3 months alone. MSDN Reference: https://technet.microsoft.com/en-us/library/jj200725(v=exchg.150).aspx
With our product GingerEx for Office365, a simple desktop app which stores the old data in DB. With our product you can overcome 90 days limitation for message tracing and also the performance will be good, since querying is done in DB instead of directly against your Office365 tenant.
GingerEx for Office365 is free for tenants with less than 50 seats, you can download it from here http://www.jijitechnologies.com/gingerex-for-office365.aspx .