title: Multiple switch values inside a loop
body: <p>I'm trying to write a switch statement that matches multiple integers in the same case. I have tried many different examples, have most recently landed on:</p>
  
  <pre><code>Get-ChildItem $folder -Filter "*.$($extension)" | Where-Object {
  
      $name = $_.Name
      $pattern = '(\d{2,4})'
      $metric = ([regex]$pattern).Matches($name)
      $variable = $metric.Item(0)
  
      switch ($variable) {
          {291,292 -contains $_} {
              Write-Host "Skip these numbers...`n"
              break
          }
          default {
              #process other numbers
          }
      }
  }
  </code></pre>
  
  <p>But this seems to get skipped and always ends up on the default bit after this, I cannot find a way to hit those two magic numbers and skip the rest of the code.</p>
  
  <p>This switch statement is inside a <code>Get-ChildItem</code>, I'm wondering if this would mean that <code>$_</code> refers to the loop and not the switch? Running out of ideas, any advice would be appreciated. I think I'm running PowerShell 4 if that helps. Thanks</p>