From: Gordon Thiesfeld Date: 2012-08-03T05:28:21+09:00 Subject: Re: WMI query with multiple and/or conditions? On Thu, Aug 2, 2012 at 9:45 AM, Charlie B. wrote: > I am using Ruby to write a format disk script. I am using WMI to > differentiate local logical disks from virtual floppies, CD-roms, and > attached SAN disks. The differentiation is in the win32_DiskDrive > class, under the "caption" section. Since this script will be run on > VMs, HP, or Dell, I need it to look for multiple conditions, and I'm not > sure how to do it. Here is a section of code that works when only > looking for VM disks: > You can use a string for :conditions. WMI::Win32_DiskDrive.find(:all, :conditions => "Caption = 'VMware Virtual disk SCSI Disk Device' OR Caption = 'HP drive' OR Caption = 'VMWare drive'" ) A few other options that occured to me are; WIn32_DiskDrive already eliminates non-disk drives. So, if I'm reading it right, you really only need to eliminate SAN drives. So, assuming your SAN disks have a model of PowerDevice by PowerPath, you could do: WMI::Win32_DiskDrive.find(:all, :conditions => "model !='PowerDevice by PowerPath'" ) or WMI::Win32_DiskDrive.all( :conditions => "NOT model LIKE '%PowerPath%'" ) > require 'ruby-wmi' > logical_disks = WMI::Win32_DiskDrive.find(:all, :conditions => { > :Caption => 'VMware Virtual disk SCSI Disk Device' } ) > > Can I add multiple conditions to it, such as two other potential > :Captions? Some way to do an 'or' in there so it will capture data from > either VMware Virtual Disks, or HP Logical Disks, or Dell Perc, etc? > > -- > Posted via http://www.ruby-forum.com/. > -- Gordon Thiesfeld http://vert.igino.us