I'm working on this powershell script to deal with exchange mailboxes, and one of the parameters (in a lot of the commands i have to run) needs a variable embedded in it under RecipientFilter. No matter what type of expansion i do, it always evaluates it literally (as $prefix) instead of expanding it. I'm not sure if there's a special way i'm supposed to escape it, or what. Ideas?
$prefix="FAKEDOM"
New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter {(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq $prefix)}
Edit: fixed variable name. Note that the question is for the second use of $prefix, the first one is working correctly.
Edit: Working solution:
New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter "(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq `"${prefix}`" )"