# Are NOT Operators available in PowerShell -Property queries ? Wildcard / string arrays / 'filter-left'

**URL:** <https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880>\
**Category:** PowerShell Help\
**Created:** [June 21, 2021, 10:46am UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880 "2021-06-21T10:46:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonny\_h](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonny_h/32/1247_2.png) [@jonny\_h](https://forums.powershell.org/u/jonny_h)\
**Post date:** [June 21, 2021, 10:46am UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/1 "2021-06-21T10:46:16Z")

</div>

Learning what’s possible, and how, playing with Win10 Event Logs and pipeline queries…  
**JUST** discovered ‘multi-search term’ (array) query syntax, _simples_

Doesn’t even need any brackets!

> Get-EventLog -LogName System -EntryType ‘Error’,‘Warning’ | select -First 10

Is it possible to do the opposite, and construct a query to say _return objects_ (eg logs) _where property_ (eg **-LogName** ) is not ‘a’,‘b’ … ?

I know it’s possible with the WHERE (filter-right) but wonder if also somehow possible to _NOT query_  
whether it requires some sort of splatting funk

Help mentions loads of great stuff. but not sure if ^ this is possible

[about Logical Operators - PowerShell | Microsoft Docs](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logical_operators?view=powershell-7.1)

```auto
{! | -NOT} <statement>

```

Does that make sense, and is it possible?

thanks

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [June 21, 2021, 11:10am UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/2 "2021-06-21T11:10:36Z")

</div>

> [@jonny\_h](#):
>
> Does that make sense

Actually not. At leat not for me.

First of all - Do not use Get-EventLog anymore as [it is deprecated](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-eventlog?view=powershell-5.1#description). Use Get-WinEvent instead.

> **[Get-WinEvent (Microsoft.PowerShell.Diagnostics) - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-winevent?view=powershell-7.4&viewFallbackFrom=powershell-7.1)**
>
> This cmdlet is only available on the Windows platform. The Get-WinEvent cmdlet gets events from event logs, including classic logs, such as the System and Application logs. The cmdlet gets data from event logs that are generated by the Windows Event...

Second … do you have a real world use case for your question? On a normal Windows system you have about 500 different logs. I’d expect you’d rather want to choose which ones to show not which ones not to show.

But … still … the parameter `-LogName` from the cmdlet `Get-WinEvent` can take an array of strings. So you still get the logs you want to show in advance and provide them as a list.

> [@jonny\_h](#):
>
> and is it possible?

Just to mention it at least once … the paramater `-LogName` of the cmdlet `Get-EventLog` can only take 1 log name at a time! 😉

---

<div class="post-metadata">

**Author:** ![jonny\_h](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonny_h/32/1247_2.png) [@jonny\_h](https://forums.powershell.org/u/jonny_h)\
**Post date:** [June 21, 2021, 4:24pm UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/3 "2021-06-21T16:24:39Z")

</div>

Thanks, maybe the example command was poor!

A rewording of the question may be,

Is it possible to use negative operators in statements like

#OPPOSITE of get arrays elements in array1 not array2 eg (1…10) && (3…5)  
#expected 3,4,5  
! ((1…10) && (3…5))  
#expected 1,2,7,8,9,10

!(Get-command get\*)  
#get any commands that don’t match get\*

I think the answer is ‘no, not possible : pipe to where-obkect’ but will test further with array and splats

Thanks!

---

<div class="post-metadata">

**Author:** ![jonny\_h](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonny_h/32/1247_2.png) [@jonny\_h](https://forums.powershell.org/u/jonny_h)\
**Post date:** [June 21, 2021, 4:26pm UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/4 "2021-06-21T16:26:20Z")

</div>

Eg for property like - source, which supports string array wildcard (I think?!)

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [June 21, 2021, 5:46pm UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/5 "2021-06-21T17:46:23Z")

</div>

> [@jonny\_h](#):
>
> Is it possible to use negative operators in statements like

If the parameter of whatever cmdlet you’re about to use takes an array of strings you can use any expression you like to produce these kind of array. The type of the output of the expression has to match the type of input expected by the cmdlet.

BUT … the more complex those expressions are the harder to read will your code be.

> [@jonny\_h](#):
>
> Eg for property like - source, which supports string array …

Again … Get-EventLog is deprecated and should not be used anymore. Use Get-WinEvent instead.

> [@jonny\_h](#):
>
> … wildcard (I think?!)

That’s your actual issue I think … you should not think or guess you should read. Most of the time the documentation is pretty clear. You should learn how to read it.

---

<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:24pm UTC](https://forums.powershell.org/t/are-not-operators-available-in-powershell-property-queries-wildcard-string-arrays-filter-left/16880/6 "2024-05-16T20:24:14Z")

</div>


