title: A better way to check if a path exists or not in PowerShell
body: <p>Is there a more concise and less error-prone way in PowerShell to check if a path DOES NOT exist?</p>
  <p>This is objectively too verbose for such a common use case:</p>
  <pre><code>if (-not (Test-Path $path)) { ... }
  if (!(Test-Path $path)) { ... }
  </code></pre>
  <p>It needs too many parenthesis and is not very readable when checking for &quot;not exist&quot;. It's also error-prone because a statement like:</p>
  <pre><code>if (-not $non_existent_path | Test-Path) { $true } else { $false }
  </code></pre>
  <p>will actually return <code>False</code>, when the user may expect <code>True</code>.</p>
  <p>What is a better way to do this?</p>
  <p><strong>Update 1:</strong> My current solution is to use aliases for <code>exist</code> and <code>not-exist</code> as explained <a href="https://stackoverflow.com/a/31888581/450913">here</a>.</p>
  <p><strong>Update 2:</strong> A proposed syntax that will also fix this is to allow the following grammar:</p>
  <pre><code>if !(expr) { statements* }
  if -not (expr) { statements* }
  </code></pre>
  <p>Here's the related issue in PowerShell repository (please vote up ): <a href="https://github.com/PowerShell/PowerShell/issues/1970" rel="nofollow noreferrer">https://github.com/PowerShell/PowerShell/issues/1970</a></p>