Ive been asked to create a Distribution Group based on Users City Value. The following Powershell commands create a example Office based group.
Once Powershell for On-premises or Office 365 shell has been started. Enter the following command changing as required:
1 |
[PS] C:\>New-DynamicDistributionGroup -Name "Melbourne Office" -RecipientFilter {RecipientType -eq "UserMailBox" -and City -eq "Melbourne"} -PrimarySmtpAddress MelbourneOffice@company.com -Alias MelbourneOffice |
To enable the Mail tip use this additional command:
1 |
[PS] C:\>Set-DynamicDistributionGroup "MelbourneOffice" -MailTip "Email to All Melbourne users." |
The following command will test and display which users will receive the email from the Distribution Group
1 |
[PS] C:\>Get-Recipient<em> -Filter (Get-DynamicDistributionGroup "Melbourne Office").recipientfilter</em> |
Note: If you are not running on a Exchange Management Shell the following post allow connection to remote Exchange Powershell – here
Very useful – Thanks!