How to get all O365 groups with members in Office 365 or Exchange Online with PowerShell

This post is Part 1/3 of Office 365 groups VS Exchange Online groups.

Office 365 or Exchange Online? What’s the difference?

It is possible that the number of groups in Office 365 is more than in Exchange Online. That is why it is always good to find out exactly what you need.

In office 365 you also see the groups that are not mail enabled. These are security groups that are used for permissions in SharePoint or something.

You can also create groups within Office 365 that are Mail-Enabled. These will appear in Exchange Online. These are also Security groups, but with an email address and can therefore also be used as a mailing group as well.

So look carefully at what you need. Is it only about the Mail-Enabled groups? Then Exchange Online is sufficient.

Do you really need all groups? Then it’s best to use Msol to get all Office 365 groups.

Let’s start scripting.

I’ve changed the blog post in 3 parts.


It’s nice that in the first blog I talk about all Office 365 groups and then use an Exchange Online script. In theory it may be that you do not have all office 365 groups then.
Groups that are not Mail enabled do occur in office 365, but not in Exchange Online.

In addition, it is nice to see how my own skills have grown compared to a few years ago, and how much I can still learn.

No idea if this post is still of real value, but I have updated for my own sake.

The script that I used for my post was not my own (stated in first paragraph). You can find the script here Alan byrne’s script.

Because the blog post has been completely changed, I have republished it. The original post dates from 16 February 2016.

A little extra

This post contains PowerShell. Would you like to learn the basics better? I have created a new website to learn basic PowerShell in an ’emulator’ environment.
Click here to go learn Basic PowerShell.

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell Automation Engineer. My main focus is PowerShell, Azure AD, Azure Infrastructure, Server Management, and Exchange (Online).

Leave a Reply

Your email address will not be published. Required fields are marked *