Syntax

$Result = @()
$AllGroups = Get-AzureADMSGroup -Filter “groupTypes/any(c:c eq ‘Unified’)” -All $true
$TotalGroups = $AllGroups.Count
$i = 1
ForEach ($Group in $AllGroups) {
Write-Progress -Activity “Processing $($Group.DisplayName)” -Status “$i out of $TotalGroups groups completed”
#Get group members
$GroupMembers = Get-AzureADGroupMember -ObjectId $Group.Id -All $true
ForEach ($User in $GroupMembers) {

Download Full Script

Purpose:To fetch details of all groups in O365
Modification:The admin can change the parameters as per need and decide on what the output will be. The output will be exported as a .csv file and will be stored in C Drive by default.
Type:PowerShell (.ps1)
Compatibility:Run with PowerShell
Tags:O365, Microsoft
Reference link: