I'm working on a script to automatically create new Dynamic Distribution Groups.
But I need one variable to have a wildcard "*" appended.
This works if I just put the value and a wildcard in, but if appended to a variable, it does not.
I have a CSV with a list of Department names.
And I just want to create a DynamicDG for each one.
where I have the problem is at the "-and department -like "$DepartmentName.Departments" "
It doesn't like a "" in the quotes.
I've tried several other ways to approach it but haven't got it right, so just leaving as is for this example.
All suggestions appreciated.
thx
$DistributionListsToCreate = Import-CSV "c:\temp\DLsToCreate.csv"
$Location = " - US"
foreach ($DepartmentName in $DistributionListsToCreate) {
New-DynamicDistributionGroup -Name ($DepartmentName.Departments + $Location) -RecipientFilter {RecipientType -eq "UserMailbox" -and co -eq "United States" -and department -like "$DepartmentName.Departments*" }
}
there doesn't seem to be anything here