# PowerShell Boolean Comparison

**URL:** <https://forums.powershell.org/t/powershell-boolean-comparison/10523>\
**Category:** PowerShell Help\
**Created:** [April 16, 2018, 10:12pm UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523 "2018-04-16T22:12:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![waynehoggett](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/waynehoggett/32/291_2.png) [@waynehoggett](https://forums.powershell.org/u/waynehoggett)\
**Post date:** [April 16, 2018, 10:12pm UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523/1 "2018-04-16T22:12:50Z")

</div>

Quick question, what does the community prefer or consider a best practice/community standard for checking if something is not true? i.e. boolean comparison

```
if (-Not (Test-Path "C:\Temp"))
```

OR

```
if (!(Test-Path "C:\Temp"))
```

OR

```
if ((Test-Path "C:\Temp") -eq $false)
```

OR something else?

---

<div class="post-metadata">

**Author:** ![daveb](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@daveb](https://forums.powershell.org/u/daveb)\
**Post date:** [April 17, 2018, 2:46am UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523/2 "2018-04-17T02:46:59Z")

</div>

I personally do the first as I find it easier to read and for others to understand what the code is testing for.

Dave.

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [April 17, 2018, 8:08am UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523/3 "2018-04-17T08:08:21Z")

</div>

I would also opt for the first, but the second isn’t bad either. They’re pretty much equivalent, but someone unfamiliar with programming may find the first easier to understand.

---

<div class="post-metadata">

**Author:** ![sconstantinou](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/sconstantinou/32/287_2.png) [@sconstantinou](https://forums.powershell.org/u/sconstantinou)\
**Post date:** [April 18, 2018, 5:36am UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523/4 "2018-04-18T05:36:27Z")

</div>

I am also going for the first one. It gives others better understanding. If the script is only for myself, I might use the second option as well.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/powershell-boolean-comparison/10523/5 "2024-05-16T20:35:10Z")

</div>


