|
|
|||||||
Been staring at this for some time now and cant find where it goes wrong. The script below fails to get the type of the drive. According to the comment in the WMIQuery UDF it should be possible to give it a where parameter. That is what the "Caption", $drive is supposed to do but I get empty results. Anyone got a bright idea? Maybe it is something small and stupid and I’ve been staring at it for to long so I’m just not seeing it. Code: $computer = "System1" $drives = WMIQuery("Caption","Win32_LogicalDisk", $computer) For Each $drive in $drives $type = WMIQuery("Type","Win32_LogicalDisk", $computer, "Caption", $drive) If $type[0] = 2 ;0 = Unknown type of drive, 1 = Removable drive, 2 = Fixed drive ;3 = Network drive, 4 = CD/DVD drive, 5 = RAM Disk ?"Fixed disk" EndIf Next |
||||||||
|
|
|||||||
There are two problems:
|
||||||||
|
|
|||||||
Yeah just noticed that after putting it away for an hour. Will do some updates and post back. |
||||||||
|
|
|||||||
This code works fine.. the "what" argument of "Type" doesn't seem valid on any sytem I've checked. Glenn |
||||||||
|
|
|||||||
BTW, if you want to see errors, change the query line in the UDF like so: Code: $objEnum = $SystemSet.ExecQuery($sQuery,"WQL",0) Useful for small queries, but may cause issues for very long / large queries. |
||||||||
|
|
|||||||
Btw, if you want a faster approach then WMI, I've written a UDF for myself a long time ago using the File System Object: Code: Function GetDrives Dim $fso, $DriveCol, $Drive, $drv $fso = CreateObject("Scripting.FileSystemObject") $DriveCol = $fso.Drives For Each $Drive in $DriveCol $drv = $fso.GetDrive($Drive) ? "Drive: "+$drv If $drv.DriveType <> 4 ? "Volume: "+$drv.VolumeName ? "Total: "+$drv.TotalSize ? "Free: "+$drv.FreeSpace EndIf ? "Type: "+$drv.DriveType ;1 = Removable, 2 = HDD, 3 = Network, 4 = CD ? Next EndFunction Although this is only for local systems. |
||||||||
|
|
|||||||
Originally Posted By: apronk ..... Although this is only for local systems. Used this approach before and it works great. Now I need the data from remote systems so in this case this is not the best option. |
||||||||
|
|
|||||||
Or run this script using my RemoteRunAs UDF ;-) |
||||||||
|
|
|||||||
Got several options now. I must be able to pull out some working code. Will post back when I'm done. |
||||||||
|
|
|||||||
I gave up entirely on remote query via WMI. My latest version of SIT (System Interrogation Tool) uses TCP socket connections to make requests and return data that's gathered, processed, and formatted locally. MUCH faster! SIT used to take almost a minute to initially gather 50-60 pieces of information, mostly via WMI calls. Using a combination of local registry, WMI, and FSO, the initial query now completes in about 10 seconds. Glenn |