Hello @365 Test Tenant and thanks for reaching out. Out of the box, is not possible to exclude disabled accounts in Exchange Dynamic Distribution Groups since the AccountDisabled
attribute is not a recognized filterable property. You can, however, set the account disabled value to one of the Exchange Custom Attributes, all which are filterable, so that you can achieve the same desired result. Setting the value to a custom attribute would preferably be done by a scheduled job or similar.
E.g.
Updating the custom attribute
Connect-ExchangeOnline
Get-User -RecipientTypeDetails "UserMailbox" | % {Set-Mailbox -Identity $_ -CustomAttribute1 $_.AccountDisabled }
Creating the Dynamic Distribution Group
Connect-ExchangeOnline
New-DynamicDistributionGroup -ConditionalCompany <COMPANY> -ConditionalCustomAttribute1 "False" # Extra parameters
Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.