title: combine multiple conditions in if-statement
body: <p>How do you chain 4 conditions together when you want either ONE set or the OTHER set of 2 condiitions to be true?</p>
  
  <p>To be more precise I want to do:</p>
  
  <p>If User is logged in AND Operating system version is Windows 10</p>
  
  <p>OR</p>
  
  <p>User is logged in AND LogonUI process is not running</p>
  
  <p>Don't bother with the commands, they all work correctly when isolated, my issue is chaining them together. <br></p>
  
  <p>For example I have : </p>
  
  <pre><code>if (
          (Get-WmiObject –ComputerName $poste –Class Win32_ComputerSystem).UserName`
          -and`
          (Get-WmiObject -Computer $poste -Class Win32_OperatingSystem).Version -like "*10*"
      )
      { echo do X }
  </code></pre>
  
  <p>which is working fine. I want to add within that same <code>if</code> the other block of conditions. I tried this, but it's not working:</p>
  
  <pre><code>if (
          (Get-WmiObject –ComputerName $poste –Class Win32_ComputerSystem).UserName`
          -and`
          (Get-WmiObject -Computer $poste -Class Win32_OperatingSystem).Version -like "*10*"`
          -or`
          (Get-WmiObject –ComputerName $poste –Class Win32_ComputerSystem).UserName`
          -and -not`
          (Get-Process -ErrorAction SilentlyContinue -ComputerName $poste -name logonui)
      )
      { echo do X }
  </code></pre>
  
  <p>How do you chain multiple "blocks" like this? I know I could do two different IF, I had it working but isn't there a way to chain it all together in one IF? (the IF contains a lot of code and i don't want to duplicate it with two IF)</p>