title: How do I negate a condition in PowerShell?
body: <p>How do I negate a conditional test in PowerShell?</p>
  
  <p>For example, if I want to check for the directory C:\Code, I can run:</p>
  
  <pre><code>if (Test-Path C:\Code){
    write "it exists!"
  }
  </code></pre>
  
  <p>Is there a way to negate that condition, e.g. (non-working):</p>
  
  <pre><code>if (Not (Test-Path C:\Code)){
    write "it doesn't exist!"
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Workaround</strong>:</p>
  
  <pre><code>if (Test-Path C:\Code){
  }
  else {
    write "it doesn't exist"
  }
  </code></pre>
  
  <p>This works fine, but I'd prefer something inline.</p>