Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your variable (at least in the sample code) is named <code>$prefix</code>, not <code>$fakedom</code>. You need to use the proper variable name in your expansion.</p> <p>Also note that the underscore char will be assumed to be part of the variable name in the replacement string, so you will need to use either <code>$($variableName)</code> or <code>${variableName}</code>. That is, you can't do a replacement like this: <code>"vanilla_$variableName_strawberry"</code>, Powershell will look for a variable named <code>variableName_Strawberry"</code>, which doesn't exist.</p> <p>All up, this is what you need:</p> <pre><code>$prefix="FAKEDOM" New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter {(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq $prefix)} </code></pre> <p><strong>Edit</strong></p> <p>Your edit makes it clear the first use of <code>$prefix</code> is fine, and it's the filter that is causing trouble. <code>-RecipientFilter</code> is a <strong>string</strong> property, but you are not enclosing your filter expression in any kind of quotes. Instead you use <code>{}</code> brackets. That's fine in general, but Powershell will not expand variables when your string is specified via <code>{}</code> brackets.</p> <pre><code>PS&gt; function Parrot([string] $Message){ $message } PS&gt; $food = 'cracker' PS&gt; Parrot {Polly want a $food ?} Polly want a $food ? </code></pre> <p>You need to change to using double-quotes:</p> <pre><code>PS&gt; Parrot "Polly want a $food ?" Polly want a cracker ? </code></pre> <p>So your filter should look like below (adding inner single quotes around the <code>$prefix</code> value):</p> <pre><code>-RecipientFilter "(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq '$prefix')" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload