in Office 365 you get three types of groups: distribution groups, dynamic distribution groups, and Office 365 groups (unified groups)…

The first two of those are based on Exchange Server and are very straight and easy to use for anyone who is familiar with Exchange Server… However the third type might look something new to them despite being at the same level of ease and straight forward!

When using Exchange Online PowerShell to list the groups, there are three commands to use for this:

Similar to the first two commands, Get-UnifiedGroup works the same way… You will get the group, then check its members attribute or property to get the other member users…

Below is a small script that I made will do the required job for you. Once the process is completed, you will get a file named O365GroupMembers.csv contains four columns!

You need to copy the script into a .ps1 file, then run it from a machine that is connected to the Office 365 using PowerShell. Note that you might want to change the execution policy on the machine that you are running the script on…

The output file will be saved in the same location from where you open the PowerShell prompt and run the script, so make sure you are on an appropriate path before running the script.

Hope you find it useful as I did!

2 thoughts on “PS: A small script to list Office 365 groups and members”

  1. Great script, but When I change from Get-UnifiedGroup to Get-DistributionGroup I get an error. What changes need to be made for it to run correctly?

    1. Hi,

      If you mean that you changed the command in line 2 of the script above, then I believe it is something to do with the properties that the distribution groups have. I do not believe they contain a property named “AccessType” and no UnifiedGroupLinks property as well that is related to the classic distribution groups… Basically that whole script is made to work with unified groups not the classic distribution groups.

      For classic distribution groups it is much simpler, you can use the below to get the list of classical distribution groups into a CSV file:

      If you are trying to type the command directly in the powershell line while you have a connection to the Office 365 powershell then it might be something for roles and security, since the security are role based and sometimes not all of the cmdlets are available for all users.

      Worth also to double-check the execution policy…

      Hope these helps 🙂

Leave a Reply

%d bloggers like this: