Forum Discussion
TaranjeetSM11
Aug 11, 2023Copper Contributor
Dynamic Distribution Group with no Disabled Accounts
Hi I'm trying to build a few Dynamic Distribution Lists in Exchange Online and want to only include Active Users (i.e., users that are marked "Active" in Azure AD). I've tried using the UserAccou...
Ankido
Feb 19, 2025Iron Contributor
Hi TaranjeetSM11,
Yes, you can create a Dynamic Distribution Group in Exchange Online using PowerShell and exclude disabled accounts.
Solution 1: In Exchange Online, use the AccountDisabled attribute in your filter rule. A disabled account in Entra ID will have AccountDisabled -eq $true
New-DynamicDistributionGroup -Name "ActiveUsersOnly" -RecipientFilter {
(RecipientType -eq 'UserMailbox') -and (AccountDisabled -ne $true)
}
Solution2: If AccountDisabled doesn’t work, you can filter based on UserPrincipalName, as disabled users sometimes lack a valid UPN.
New-DynamicDistributionGroup -Name "ActiveUsersOnly" -RecipientFilter {
(RecipientType -eq 'UserMailbox') -and (UserPrincipalName -like '*@*')
}
If you need any more help, feel free to reach out.
- TiberiaFeb 25, 2025Copper Contributor
These dont work and throw an error that the filter syntax is invalid.
I dont understand Microsoft sometimes.- AnkidoFeb 26, 2025Iron Contributor
Hi Tiberia,
Sometimes the reasons could be:
- Authentication Issues
- Missing or Outdated Module
- Expired Session
- Insufficient Permissions
- Network Connectivity Issues
- Throttling or API Limits
Could you please provide the error message or share a screenshot?