# Using -contains for $null

**URL:** <https://forums.powershell.org/t/using-contains-for-null/18625>\
**Category:** PowerShell Help\
**Created:** [February 19, 2022, 11:59am UTC](https://forums.powershell.org/t/using-contains-for-null/18625 "2022-02-19T11:59:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-doherty](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@tom-doherty](https://forums.powershell.org/u/tom-doherty)\
**Post date:** [February 19, 2022, 11:59am UTC](https://forums.powershell.org/t/using-contains-for-null/18625/1 "2022-02-19T11:59:11Z")

</div>

Hello All,

Staring at something that is not making sense to me this morning… I need to scan volumes and return all the volumes on servers that have volumes formatted with ReFS or that have been borked and are now flagged as RAW.

```auto
$volumes = gwmi win32_volume

If ($Volumes.filesystem -contains 'ReFS' -or $null){
    "Found them"
}
Else {
    "Not there"
}

```

If I look for only $null - it works, finds them and returns True. It’s only when I join them with an -or that the $null stops being found. It does still rind the ReFS and return True, it just ignores the $null.

What am I doing wrong? How should I be doing it?

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [February 19, 2022, 12:19pm UTC](https://forums.powershell.org/t/using-contains-for-null/18625/2 "2022-02-19T12:19:39Z")

</div>

Hello, welcome back, it’s been a while 👋

You need a conditional statement after the `-or` operator:

This should work:

```auto
(($Volumes.filesystem -contains 'ReFS') -or ($Volumes.filesystem -contains $null))

```

---

<div class="post-metadata">

**Author:** ![tom-doherty](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@tom-doherty](https://forums.powershell.org/u/tom-doherty)\
**Post date:** [February 19, 2022, 1:50pm UTC](https://forums.powershell.org/t/using-contains-for-null/18625/3 "2022-02-19T13:50:11Z")

</div>

Thanks Matt.

Duh oh! Of course! Too long looking at it!

Many thanks indeed.

---

<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:19pm UTC](https://forums.powershell.org/t/using-contains-for-null/18625/4 "2024-05-16T20:19:32Z")

</div>

Closed on May 16, 2024, 8:19pm UTC


