Home
List members of a dynamic distribution group
Published: Friday, 20 September 2019 | Categories: Office365 | Keywords: Powershell | Status: Posted | Created: Friday, 20 September 2019 | Author: paul

A simple powershell script to list the members of a dynamic distribution group in Office 365.

# List members of a dynamic distribution list

Param( 
    [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)] 
    [string] $groupname
) 

if ($Session.state -eq 'Broken' -or !$Session) { 
	write-host "Connecting to Exchange Online Powershell.."
	$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential (Get-Credential) -Authentication Basic -AllowRedirection
	Import-PSSession $Session
}

$Group = Get-DynamicDistributionGroup $groupname
Get-Recipient -RecipientPreviewFilter $Group.RecipientFilter -OrganizationalUnit $Group.RecipientContainer

 


Add Comment
No Comments.