Search code examples
wmipowershell-3.0

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.


Solution

  • Took me a few but i finally figured it out.

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