Governance and Groups retrieving inactive Office 365 Groups

Governance and Groups retrieving inactive Office 365 Groups

Lets start with the fact that groups are awesome! Their easy to create, almost everyone can work with them and you’ve got almost everything you need to collaborate in a team. Now there are some downsides as well, due to the fact that you can create them so easily you might end up with loads of them. In a previous post I explained how you can disable groups for specific users. If you however where to late doing so, or still consider allowing everyone to create them there are a few handy tips you can use to maintain your environment. As groups are created in Office 365 they consists of multiple components. Groups introduce a new identity called the UnifiedGroup in PowerShell. As group consists of conversations and calendars that live in Exchange and files that live in SharePoint you can write some smart scripts to apply a form of governance to your groups.

Retrieving Office 365 Group date and time info

Starting with the new Get-UnifiedGroup commandlet you could create a quick query of all the groups that where created in a specific timeslot. For instance all groups created over the last year, and output their displayname, the manager and when the group is created. You can also do the same for when a group is changed.

Get-UnifiedGroup | Where-Object {$_.WhenCreated -ge (Get-Date).AddDays(-365)} | `
FT DisplayName, ManagedBy, WhenCreated 
Get-UnifiedGroup | Where-Object {$_.WhenChanged -ge (Get-Date).AddDays(-365)} | ` 
FT DisplayName, ManagedBy, WhenCreated 

The first line gets all the groups that where created over the last 365 days, while the second line shows all the groups that have changed over that period. You can apply specific filters on name or a different timespan based on your requirements. This is pretty basic functionality that you can use to get an overview of what happened in a specific timeslot in regards to the basics of the group.

Retrieving Office 365 Active Groups by conversation

The thing is that not all groups get updated frequently. You typically would like something to determine group activity based on activity in the group. As the WhenChanged property of a group only gets updated when someone actually changes the description of the group. Other activities like when someone posts a message gets ignored. To achieve that you can could check the Mailbox statistics of the group. Each group gets its own e-mail box and if you send an e-mail to the group, or read an e-mail in the LastLogonTime property. By retrieving that property for all groups you can create an overview of when the last conversation of a group took place.  So lets assume we want retrieve all groups that had active conversations over the last seven days.

Get-UnifiedGroup | Foreach-Object { Get-MailboxStatistics -Identity $_.Identity } | `
Where-Object {$_.LastLogonTime  -ge (Get-Date).AddDays(-7)}

As Office 365 Groups partially resides in Exchange not only the conversations count towards the mailbox. Any action that takes place in the calendar will count towards this date- timestamp as well. Any actions in the notebook or files however will not show up unless you share it within a conversation.

Retrieving Office 365 Active Groups by content

So in order to retrieve actions on the OneNote or the files in a group you should work with site they reside in. In order to work with the site you have to retrieve all the groups and use their SharePointDocumentsUrl property. If you have that property you can retrieve each site and get the LastContentModifiedDate that will tell you when the content has been modified.

Get-UnifiedGroup | Foreach-Object { `
    Get-SPOSite -Identity $_.SharePointDocumentsUrl.replace("/Shared Documents", "")} | ` 
    FT Title, Url, LastContentModifiedDate

Combining both the conversation and content commands you can get a in-depth view of what happens in your groups, and how active they are. Based on that knowledge you can use the Remove-UnifiedGroup to delete a group if they are no longer active.  Or actively report manager of a group that their group will be deleted if there is no more activity on the group. 

Leave a Reply