The filter conditions in Dynamic Distribution Group have the logical AND relation. What does it mean?
Let me create several mailboxes first;
$password=read-host "Enter password please!" -asSecureString
$firstName="George"
$lastName="Allistair"
$city="Vancouver"
$company="Telus"
$province="BC"
$department="Network"
New-Mailbox -Name "$firstName $lastName" -Alias "$firstName.$lastName" -OrganizationalUnit 'Terrace.com/Research' -UserPrincipalName "$firstName.$lastName@Terrace.com" -SamAccountName "$firstName.$lastName" -FirstName $firstName -Initials '' -LastName $lastName -Password $password -Database 'USA\First Storage Group\Mailbox Database'
Set-User -Identity "Terrace.Com/research/$firstName $lastName" -City $city -Company $company -StateOrProvince $province -Department $department
$firstName="Alan"
$lastName="King"
$city="Vancouver"
$company="Shaw"
$province="Alberta"
$department="Network"
New-Mailbox -Name "$firstName $lastName" -Alias "$firstName.$lastName" -OrganizationalUnit 'Terrace.com/Research' -UserPrincipalName "$firstName.$lastName@Terrace.com" -SamAccountName "$firstName.$lastName" -FirstName $firstName -Initials '' -LastName $lastName -Password $password -Database 'USA\First Storage Group\Mailbox Database'
Set-User -Identity "Terrace.Com/research/$firstName $lastName" -City $city -Company $company -StateOrProvince $province -Department $department
$firstName="Steve"
$lastName="Paulie"
$city="Vancouver"
$company="Shaw"
$province="BC"
$department="Marketing"
New-Mailbox -Name "$firstName $lastName" -Alias "$firstName.$lastName" -OrganizationalUnit 'Terrace.com/Research' -UserPrincipalName "$firstName.$lastName@Terrace.com" -SamAccountName "$firstName.$lastName" -FirstName $firstName -Initials '' -LastName $lastName -Password $password -Database 'USA\First Storage Group\Mailbox Database'
Set-User -Identity "Terrace.Com/research/$firstName $lastName" -City $city -Company $company -StateOrProvince $province -Department $department
$firstName="Paul"
$lastName="Bellitown"
$city="Vancouver"
$company="Telus"
$province="BC"
$department="Network"
New-Mailbox -Name "$firstName $lastName" -Alias "$firstName.$lastName" -OrganizationalUnit 'Terrace.com/Research' -UserPrincipalName "$firstName.$lastName@Terrace.com" -SamAccountName "$firstName.$lastName" -FirstName $firstName -Initials '' -LastName $lastName -Password $password -Database 'USA\First Storage Group\Mailbox Database'
Set-User -Identity "Terrace.Com/research/$firstName $lastName" -City $city -Company $company -StateOrProvince $province -Department $department
$firstName="Scott"
$lastName="Berger"
$city="Vancouver"
$company="Telus"
$province="BC"
$department="Marketing"
New-Mailbox -Name "$firstName $lastName" -Alias "$firstName.$lastName" -OrganizationalUnit 'Terrace.com/Research' -UserPrincipalName "$firstName.$lastName@Terrace.com" -SamAccountName "$firstName.$lastName" -FirstName $firstName -Initials '' -LastName $lastName -Password $password -Database 'USA\First Storage Group\Mailbox Database'
Set-User -Identity "Terrace.Com/research/$firstName $lastName" -City $city -Company $company -StateOrProvince $province -Department $department
//To include all members in both BC and Alberta provinces, you use comma as highlighted below: the comma represents the OR relation.
New-DynamicDistributionGroup -Name "NetworkSupport" -OrganizationalUnit 'Terrace.COM/Research' -DisplayName 'Network Support Group' -Alias 'NetworkSupport' -IncludedRecipients "MailboxUsers" -ConditionalStateOrProvince 'BC','Alberta'
$network = Get-DynamicDistributionGroup -Identity "NetworkSupport"
Get-Recipient -RecipientPreviewFilter $network.RecipientFilter
Name
---- -------------
Alan King
Kevin Smith
George Allistair
Steve Paulie
Paul Bellitown
Scott Berger
//ConditionalDepartment and ConditionalCompany parameters are the relation:AND
New-DynamicDistributionGroup -Name Marketing -OrganizationalUnit 'Terrace.com/Research' -DisplayName 'Marketing Group Canada' -Alias 'Marketing' -IncludedRecipients 'Mailboxusers' -ConditionalDepartment Marketing -ConditionalCompany Telus
$Marketing = Get-DynamicDistributionGroup -Identity "Marketing"
Get-Recipient -RecipientPreviewFilter $Marketing.RecipientFilter
Name
-------
Scott Berger