Hello, I have a weird issue with variable concatenation… I wrote a script to create an Exchange distribution list. In my script, I have 2 param : the name of the list to create and the member to add.
In my distribution list, I always want a specific address + the one that was passed in parameters. What I want to do is add adressToAdd@MYDOMAIN.qc.ca to the $member variable (see code below…)
Param(
[string]$cmdDistributionListName,
[string]$cmdMember
)
function CreerListeDistributionApple {
param ([string]$distributionListName, [string]$member)
$member = $member,"addressIAlwaysWantToAdd@MYDOMAIN.qc.ca"
#write-host $member
#write-host user@MYDOMAIN.qc.ca,adressToAdd@MYDOMAIN.qc.ca
New-DistributionGroup -Name $distributionListName -Type "Distribution" -Members $member
So I call the function and add a member (let’s say user@MYDOMAIN.qc.ca)...$member = user@MYDOMAIN.qc.ca...after that, I want $member to equal user@MYDOMAIN.qc.ca,addressIAlwaysWantToAdd@MYDOMAIN.qc.ca
I have tried different kind of concatenations, it does not seem to work.
If in the New-DistributionGroup cmdlet, I replace –Members with user@MYDOMAIN.qc.ca,adressToAdd@MYDOMAIN.qc.ca, it works !
When I uncomment the Write-Host, both are the same! If I use –Member $member, then I get an error that the object "user@MYDOMAIN.qc.ca adressToAdd@MYDOMAIN.qc.ca" is inexistant... it looks like my concatenation makes the $member variable in one
block ("xxx xxxx" instead of xxx,xxx)
Any idea on how I should work with this ???
Thanks in advance