title: Powershell foreach loop with multiple if statements
body: <p>I have a script snippet that basically gets some unformated xml type output from a command.</p>
  
  <p>Then in a defined filter section I'm transforming that into xml and run a search loop on each node, as from the part below.</p>
  
  <p>What I'm trying to figure out is how I can make a multiple if -and loop, like
  if (($CimProperty.VALUE -eq $somevariable) -and ($CimProperty.VALUE -eq $something-else))</p>
  
  <p>The only problem is that since it's a foreach loop it won't take it, as it takes each property at a time and then the 'if statement -and portion' for it, which doesn't work since it's the same xml type property section. 
  In other words the loop doesn't go through the entire array to identify both conditions from the if statement.</p>
  
  <p>PS code snippet: </p>
  
  <pre><code>filter Import-CimXml
  {
      $CimXml = [Xml]$_
      $CimObj = New-Object -TypeName System.Object
      foreach ($CimProperty in $CimXml.SelectNodes(“/INSTANCE/PROPERTY”))
      {
          if ($CimProperty.VALUE -eq $somevariable)
            {
               write-host "found it"
            }
      }
   }
  </code></pre>
  
  <p>I hope the scenario is clear, thanks everyone in advance!</p>