gcue Posted July 21, 2010 Posted July 21, 2010 (edited) The first script grabs disk info like size, serial number, etc. but i was not able to get "Model" from Win32_LogicalDisk. the second script gets "Model". trying to figure out a way I can reference the correct disk to make sure the second script pulls the model from the corresponding disk in first script. any ideas? $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $row = 1 $objWMIService = ObjGet("winmgmts:\\" & $asset & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $description = $objItem.Description If $description <> "Network Connection" And $description <> "CD-ROM Disc" And $description <> "3 1/2 Inch Floppy Drive" Then ConsoleWrite("device_id = " & $objItem.DeviceID) ConsoleWrite("free_space = " & $objItem.FreeSpace) ConsoleWrite("size = " & $objItem.Size) ConsoleWrite("volume_serial_number = " & $objItem.VolumeSerialNumber) EndIf Next EndIf $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $asset & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_DiskDrive") For $objItem In $colItems ConsoleWrite("model = " & $objItem.Model) Next Edited July 21, 2010 by gcue
eltorro Posted July 21, 2010 Posted July 21, 2010 On 7/21/2010 at 8:07 PM, 'gcue said: The first script grabs disk info like size, serial number, etc. but i was not able to get "Model" from Win32_LogicalDisk. the second script gets "Model". trying to figure out a way I can reference the correct disk to make sure the second script pulls the model from the corresponding disk in first script. any ideas? $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $row = 1 $objWMIService = ObjGet("winmgmts:\\" & $asset & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $description = $objItem.Description If $description <> "Network Connection" And $description <> "CD-ROM Disc" And $description <> "3 1/2 Inch Floppy Drive" Then ConsoleWrite("device_id = " & $objItem.DeviceID) ConsoleWrite("free_space = " & $objItem.FreeSpace) ConsoleWrite("size = " & $objItem.Size) ConsoleWrite("volume_serial_number = " & $objItem.VolumeSerialNumber) EndIf Next EndIf $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $asset & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_DiskDrive") For $objItem In $colItems ConsoleWrite("model = " & $objItem.Model) Next Looks like it is pretty tricky. Converted this from here:http://www.tek-tips.com/viewthread.cfm?qid=1554136&page=1 expandcollapse popup$asset = "." $objWMIService = ObjGet("winmgmts:\\" & $asset & "\root\cimv2") $colDiskDrives = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive") For $objDrive In $colDiskDrives _ConsoleWrite("Physical Disk: " & $objDrive.Caption & " -- " & $objDrive.DeviceID) $strDeviceID = StringReplace($objDrive.DeviceID, "\", "\\") $colPartitions = $objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _ $strDeviceID & """} WHERE AssocClass = " & _ "Win32_DiskDriveToDiskPartition") For $objPartition In $colPartitions _ConsoleWrite("Disk Partition: " & $objPartition.DeviceID) $colLogicalDisks = $objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _ $objPartition.DeviceID & """} WHERE AssocClass = " & _ "Win32_LogicalDiskToPartition") For $objLogicalDisk In $colLogicalDisks ; If $objLogicalDisk.VolumeName = "System" Then ;_ConsoleWrite("Logical Disk: " & $objLogicalDisk.DeviceID) _ConsoleWrite("device_id = " & $objLogicalDisk.DeviceID) _ConsoleWrite("free_space = " & $objLogicalDisk.FreeSpace) _ConsoleWrite("size = " & $objLogicalDisk.Size) _ConsoleWrite("volume_serial_number = " & $objLogicalDisk.VolumeSerialNumber) _ConsoleWrite("model = " & $objDrive.Model) ; EndIf Next _ConsoleWrite() Next _ConsoleWrite() Next Func _ConsoleWrite($sMsg="") ConsoleWrite($sMsg&@LF) EndFunc Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
gcue Posted July 21, 2010 Author Posted July 21, 2010 (edited) hey eltoro...thanks for your help on this!it works when i chose remote pc's that don't have solid state drives.. weird. Quote (4) : ==> Variable must be of type "Object".:$colDiskDrives = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")$colDiskDrives = $objWMIService^ ERROR Edited July 21, 2010 by gcue
gcue Posted July 22, 2010 Author Posted July 22, 2010 it was a networking issue... works great!!! many thanks eltorro!!!!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now