Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use NOT LIKE with Get-WmiObject Win32_Directory -filter

Using Powershell 3.0 I'm trying to utilize the following command line's "-filter" option to filter out directories I don't want scanned when I'm trying to pull a list of directories remotely via WMI.

The LIKE option works fine, however I haven't been able to figure out what works for NOT LIKE. I've tried !LIKE, NL, & NOT LIKE. So far, powershell no likey...

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

Let me be clear here. I am aware of the WHERE option that will accomplish this but that option ends up scanning everything, it just doesn't display what you filter out.

like image 659
Ammer Avatar asked Sep 11 '13 16:09

Ammer


1 Answers

Took me a few but i finally figured it out.

Get-WmiObject Win32_Directory -ComputerName "." -filter "NOT name LIKE '%oracle%'" | select name
like image 151
Ammer Avatar answered Oct 02 '22 15:10

Ammer