Exchange OnlineLatestPower ShellSoftware Support

How to create reports on all groups and their members PowerShell

Open Power Shell as an Administrator

Power Shell ITDukes

Go to Start
Search for Power Shell
Right click on Windows Power Shell
Run as Administrator

Run the following commands

Set-ExecutionPolicy RemoteSigned

(Need to configure this setting only once on your computer)
-Press “A” or “Y”
Press Enter

$UserCredential = Get-Credential

Credentials Office 365 PowerShell

Windows Power Shell Credential Request
Enter Admin’s Username & Password

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

For report on all groups and their members

 function Get-AllO365Members
 {
     Try
     {
      $O365Groups=Get-UnifiedGroup
         foreach ($O365Group in $O365Groups)
         {
             Write-Host "Group Membership: " $O365Group.DisplayName -ForegroundColor Green
             Get-UnifiedGroupLinks –Identity $O365Group.Identity –LinkType Members
             Write-Host
         }
     }
     catch [System.Exception]
     {
         Write-Host -ForegroundColor Red $_.Exception.ToString()
     }
 }
 Get-AllO365Members