title: Using "-Filter" with a variable
body: <p>I try to filter out something like this:</p>
  
  <pre><code>Get-ADComputer -Filter {name -like "chalmw-dm*" -and Enabled -eq "true"} ...
  </code></pre>
  
  <p>This works like a charm and gets exactly what I want...</p>
  
  <p>Now I want the "name -like ..." part as a variable like this:</p>
  
  <pre><code>Get-ADComputer -Filter {name -like '$nameregex' -and Enabled -eq "true"} |
  </code></pre>
  
  <p>I checked several questions (for example, <em><a href="https://stackoverflow.com/questions/19782255/powershell-ad-module-variables-in-filter">PowerShell AD Module - Variables in Filter</a></em>), but this isn't working for me.</p>
  
  <p>I tried it with the following:</p>
  
  <pre><code>$nameRegex = "chalmw-dm*"
  $nameRegex = "`"chalmw-dm*`""
  </code></pre>
  
  <p>And also in the <code>Get-ADComputer</code> command with those <code>'</code> and without.</p>
  
  <p>Could anyone give me some hints?</p>