title: Powershell Match a string that may contain asterix
body: <p>I'm running into issues with a string that gets parsed a certificate friendly name and attemps a lookup to see if it already exists. When the friendly name contains a '*' the script bombs.</p>
  
  <p>I know I could escape the '*', but I don't have control of when it's parsed to the script. What is the best way of either escaping on the fly or matching strings when/if they contain metacharacters?</p>
  
  <pre><code># this does not work
  # Bad argument to operator '-match': parsing "*.test.com" - Quantifier {x,y} following nothing..
  if(Get-ChildItem cert:\ -Recurse | Where-Object {$_.FriendlyName -and $_.FriendlyName -match '*.test.com'} | Select-Object -First 1) { 
    exit 1 
  } else { 
    exit 0 
  }
  
  # this works fine
  if(Get-ChildItem cert:\ -Recurse | Where-Object {$_.FriendlyName -and $_.FriendlyName -match 'string.test.com'} | Select-Object -First 1) { 
    exit 1 
  } else { 
    exit 0 
  }
  </code></pre>