Showing posts with label Distribution Group. Show all posts
Showing posts with label Distribution Group. Show all posts

2015/08/29

PowerShell/Office 365 - Get an Exchange Online user's distribution groups efficiently

In my previous post I showed how to retrieve the membership of one or multiple groups. In today's post I want to find the Distribution groups a user belongs to.

There are multiple approaches you could be using to gather this information but as an example I'll re-use the same one-liner from my previous article and simply filter with Where-Object to find a particular User.

This is probably the route PowerShell beginners would take and it is working 'Fine' in a small environment but not very efficient, you'll see in the following example.

In this environment, there are a bit more than 1800 Distribution Groups. I want to know which Distribution Group I'm member of.

Retrieving the count of Distribution Groups and an User account in Office 365


2015/08/24

PowerShell/Office 365 - Get the distribution groups membership

I was recently looking at Office365/Exchange Online to retrieve Distribution Group membership. This is pretty simple using something like:
Get-DistributionGroupMember -Identity "Marketing"

Not that prior to perforce the following command you need to be already connected to Office365, see this post.

Retrieving all members of each Distribution Group

Now if I want to retrieve all the Distribution group members, it's bit trickier you'll see. First I started by listing the groups members. My PowerShell instinct made me type Get-DistributionGroup|Get-DistributionGroupMember but it did not work, see below:



As the error message is stating that this Cmdlet does not accept input :-/

By using Get-Help on Get-DistributionGroupMember, we can check the parameters accepting Input:

(Get-Help Get-DistributionGroupMember).parameters.parameter|Select-Object name,parametervalue,pipelineinput