Summary of issue
I have two variables with the same content, the only difference is how the variable was populated, when i try to use it in exchange management shell i get for one variable an error while the other one works as it should be.
Long explanation - With examples
I created a transport rule to block emails from specific senders, I'm trying to use one line in powershell to add users the the block list.
- I tried first the regular way to manipulate an array using
set-transportrule -identity "whatever" -from @{add="whoever"}
But this doesn't work, i researched it and saw that it's by design, so i gave up on this. - So I tried something else
set-transportrule -identity "whatever" -from (get-transportrule -identity "whatever").from,"whoever2"
But i again hit a road block. - So tried
set-transportrule -identity "whatever" -from "whoever1","whoever2"
and it worked beautifully. But this is not what i want I'm trying to add to the existing values.
This got me thinking, so i started testing to find the differences between the two arrays
- First I created a variable
variable1 = "whoever1","whoever2"
and used it like thisset-transportrule -identity "whatever" -from $variable1
and it worked as it should be. - So I went ahead and created another variable
variable2 = (get-transportrule -identity "whatever").from,"whoever2"
and tried using itset-transportrule -identity "whatever" -from $variable2
, but this didn't work.
I compared the variable types and they are identical. Whats going on here? What am i missing
Thanks in advance for any help!