title: How can you check if a variable is in an array in PowerShell?
body: <p>I am attempting to create an audit of mailbox permissions in powershell and would like to remove specific accounts from the output within the powershell script rather than manually afterwards.</p>
  
  <p>In order to do this I am looking for a way to compare the contents of an array against a single string in powershell.</p>
  
  <p>For example, if I was to declare an array:</p>
  
  <pre><code>$array = "1", "2", "3", "4"
  </code></pre>
  
  <p>I then want to find a way to do something like the below:</p>
  
  <pre><code>$a = "1"
  $b = "5"
  
  if ($a -ne *any string in $array*) {do something} #This should return false and take no action
  
  if ($b -ne *any string in $array*) {do something} #This should return true and take action
  </code></pre>
  
  <p>I am at a loss for how this would be accomplished, any help is appreciated</p>