Index ¦ Archives ¦ Atom

Listing O365 group members

Powershell is an ugly hammer but it occasionally drives a nail effectively, or at least saves a bunch of copy-paste-reformat busy-work

So you need to get a list of members of a specific O365 group, and don't want to deal with horrible formatting issues after you copy/paste it out of their web portal? Powershell can help!

  1. Connect to O365 PowerShell [docs]:

    Connect-MsolService

  2. Find the group you're looking for (you need the group object ID)

    Get-MsolGroup -SearchString '<group name>'

  3. Get the list of members for the group, sort it by email address, convert them from objects into strings, and copy the list to the clipboard:

    Get-MsolGroupMember -GroupObjectId <group object ID> | sort-object -Property EmailAddress | select EmailAddress | Out-String | Set-Clipboard

  4. Paste that list wherever you need it and move on with life.

You could of course turn this into a scheduled job of some sort that emails the results, or somesuch.

© Jamie Finnigan; opinions my own and not my employers. Built using Pelican. Modified from theme by Giulio Fidente on github.