How to use NOT LIKE with Get-WmiObject Win32_Directory -filter

Using Powershell 3.0 I am trying to use the following "-filter" command line option to filter out directories that I do not want to scan when I try to remotely delete a directory list through WMI.

The LIKE parameter works fine, but I was not able to figure out what works for ANYTHING. I tried! LIKE NL, DO NOT LIKE. Until now, powershell did not like it ...

Get-WmiObject Win32_Directory -ComputerName "." -filter "name NOT LIKE '%oracle%'" | select name 

Let me clarify here. I know the WHERE option, which will do this, but this parameter completes the scan of everything, it just does not display what you are filtering.

+6
source share
1 answer

Took me a few, but I finally figured it out.

 Get-WmiObject Win32_Directory -ComputerName "." -filter "NOT name LIKE '%oracle%'" | select name 
+13
source

Source: https://habr.com/ru/post/953641/


All Articles