# Dynamic Group

{% hint style="info" %}
Dynamic group membership updates are expected to process for all groups within 24 hours. [Learn more](https://docs.microsoft.com/azure/active-directory/enterprise-users/groups-create-rule?WT.mc_id=Portal-Microsoft_AAD_IAM#check-processing-status-for-a-rule)
{% endhint %}

Rules for the Dynamic Group

```
(user.country -in ["MY","SG","VN","CN","TW","HK","IN","ID"]) and 
(user.displayName -in ["Snow Wang","Wenjian Khor"]) and 
(user.accountEnabled -eq True) and (user.mail -contains "jabil.com")
```

This will create a group with admin and requestor for the next step, which is disabling the Welcome email since the scope is huge for this group, and we don't want to spam everyone's inbox

Get the current setting for the group with the ExchangePowershell module

```powershell
Install-Module ExchangePowershell
Import-Module ExchangePowershell

Connect-ExchangeOnline

#Get current setting and update
Get-UnifiedGroup -Identity "GroupEmail@domain.com" | Select WelcomeMessageEnabled
Set-UnifiedGroup -Identity "GroupEmail@domain.com" -UnifiedGroupWelcomeMessageEnable:$false

#Check and compare with previous output
Get-UnifiedGroup -Identity "GroupEmail@domain.com" | Select WelcomeMessageEnabled
```

Now replace the `user.displayName -in ["Snow Wang","Wenjian Khor"])` with `user.displayName -NotIn ["People to exclude from the group"])`

By default, all emails to this "Group Address" will end up in the Group inbox. We need to adjust the setting below to get the email forwarded to the group users.

<figure><img src="https://2627915664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC5L8BFhTKgXFngIiQkEm%2Fuploads%2FXpc0jlBFACEKzpfyK2TN%2Fimage.png?alt=media&#x26;token=4d7999d0-7182-462c-8f97-4095fea112cd" alt=""><figcaption></figcaption></figure>

If required, control who can send email to this DL via this setting on Exchange Admin

<figure><img src="https://2627915664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC5L8BFhTKgXFngIiQkEm%2Fuploads%2FW4cD34NB3PQHlGMEFtpm%2Fimage.png?alt=media&#x26;token=e488ee16-0de9-4ac8-974f-340b39f57a56" alt=""><figcaption></figcaption></figure>

The below error will show if you do not have permission to send email to this group

<figure><img src="https://2627915664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC5L8BFhTKgXFngIiQkEm%2Fuploads%2FXxDO7rVsLx0lcIGYFpbn%2Fimage.png?alt=media&#x26;token=d0f8ecc3-acf7-44e1-9b66-4cd2d53d5fba" alt=""><figcaption></figcaption></figure>
