Jon Brelie
asked on
Powershell variable treated as NULL in New-GlobalAddressList cmdlet
I can't wrap my head around what's going on here.
This works from the powershell commandline:
CustomAttribute10 -eq 'ThisGuy'
However, if I do the exact same thing in a script, I get a malformed recipient filter
The above executes with no errors, BUT - Get-GlobalAddressList ThatGuy_GAL returns a recipient filter that looks like this:
-not(CustomAttribute10 -ne $null)
What?
This works from the powershell commandline:
New-GlobalAddressList -name ThisGuy_GAL -recipientFilter {CustomAttribute10 -eq ThisGuy}
Get-globalAddressList Thisguy_GAL returns the expected recipient filter that looks like this:CustomAttribute10 -eq 'ThisGuy'
However, if I do the exact same thing in a script, I get a malformed recipient filter
$uniqueID = "ThatGuy"
New-GlobalAddressList -Name "$($uniqueID)_GAL" -RecipientFilter {CustomAttribute10 -eq $uniqueID}
The above executes with no errors, BUT - Get-GlobalAddressList ThatGuy_GAL returns a recipient filter that looks like this:
-not(CustomAttribute10 -ne $null)
What?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Magnificent! You have no idea how many combinations of quotes and backticks I've tried to get this working. Thank you!
ASKER
works perfectly!
I know I have tried a few times as well.
ASKER
Okay, that makes sense. But why is that value being interpreted as NULL in the recipient filter and not in the name? I've tried numerous forms of syntax... can anyone provide me with the correct version?