Creating Office 365 Dynamic group for Users only

Connect to Exchange online using PowerShell
https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx

To exclude shared and resource mailboxes use the following,

New-DynamicDistributionGroup -Name “All Staff” -RecipientFilter {(RecipientType -eq ‘UserMailbox’) -and (-not(RecipientTypeDetailsValue -eq ‘SharedMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘RoomMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘EquipmentMailbox’))}

or update an existing one

Get-DynamicDistributionGroup -Name “All Staff” | Set-DynamicDistributionGroup -RecipientFilter {(RecipientType -eq ‘UserMailbox’) -and (-not(RecipientTypeDetailsValue -eq ‘SharedMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘RoomMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘EquipmentMailbox’))}

To view membership of a group

$g = Get-DynamicDistributionGroup “All Staff”
Get-Recipient -RecipientPreviewFilter $g.RecipientFilter

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s