Hi All, its been a while
i have knocked together a script to create dynamic DLs based on a CSV
CSV looks like below
CostCentre | CostcentreName |
---|---|
99-001 | Testing 1 |
99-002 | Testing 2 |
Script here
$filepath = "c:\temp\QBDGCCs.csv"
$CCs = Import-CSV $filepath
#Collection of Cost Centre column
Foreach ($CC in $CCs)
{
$CCnumber = $cc.costcentre
$CCName = $cc.CostcentreName
$QBDGName = "$ccnumber $CCName"
#$Managedby = "Claire Colthirst"
#$Note = "New Future Org CC - created 21/02/22"
New-DynamicDistributionGroup -Name $QBDGName -OrganizationalUnit 'global.arup.com/Global/Dynamic Distribution Groups/Cost Centres' -Alias "$CCnumber-QBDG" -PrimarySmtpAddress "$CCnumber-QBDG@arup.com" -RecipientContainer 'global.arup.com’ -RecipientFilter { ((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailUser')) -and
(EmailAddresses -like '*@arup.mail.onmonmicrosoft.com') -and
(CustomAttribute15 -eq 'human:staff') -and
(Department -like "$CCnumber*") } }
$DG = Get-DynamicDistributionGroup "99-001 testing 1"
Get-Recipient -RecipientPreviewFilter $DG.RecipientFilter -OrganizationalUnit $DG.RecipientContainer -ResultSize unlimited
$DG.RecipientFilter
All runs fine however there is no members as i would expect, querying the filter i get
((((((((((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailUser'))) -and (EmailAddresses -like '*@xxxx.mail.onmonmicrosoft.com'))) -and (Custo
mAttribute15 -eq 'human:staff'))) -and (Department -like '$CCnumber*'))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (
-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq
'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and
(-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox')))
```
Notice department (Department -like '$CCnumber*'))) why is this not populating the number, $ccnumber has the correct value as i use it for alias
thanks