Managing and Monitoring Disk Drives

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Physical hard disk drives are the primary storage medium for information in any computing environment. Although organizations often use devices such as tape drives and compact disc drives for archiving data, these devices are not suited for day-to-day storage of user data. Only physical hard disks offer the speed and ease of use required for storing data and for running applications and the operating system.

To efficiently manage data, it is important to have a detailed inventory of all your physical disks, their capabilities, and their capacities. You can use the Win32_DiskDrive class to derive this type of inventory. As shown in Table 10.1, you can use the Win32_DiskDrive class to enumerate the disk drives installed on a computer and to return data such as the type of interface used by the drive, the drive manufacturer and model number, and the number of tracks, cylinders, sectors, and heads that compose the drive hardware.

Table 10.1   Win32_DiskDrive Properties

PropertyDescription
BytesPerSectorNumber of bytes in each sector for the physical disk drive.
CapabilitiesArray of capabilities of the disk drive. Values include:

0 Unknown

1 Other

2 Sequential Access

3 Random Access

4 Supports Writing

5 Encryption

6 Compression

7 Supports Removable Media

8 Manual Cleaning

9 Automatic Cleaning

10 SMART Notification

11 Supports Dual-Sided Media

12 Ejection Prior to Drive Dismount Not Required

CompressionMethodAlgorithm or tool used by the device to support compression.
DescriptionDescription of the disk drive.
DeviceIDUnique identifier of the disk drive with other devices on the system.
IndexPhysical drive number of the given drive. A value of 0xFF indicates that the given drive does not map to a physical drive.
InterfaceTypeInterface type of physical disk drive, typically IDE or SCSI.
ManufacturerName of the disk drive manufacturer.
MediaTypeType of media used or accessed by this device. Values are:
  • Removable media
  • Fixed hard disk
  • Unknown
ModelManufacturer s model number of the disk drive.
NameLabel by which the disk drive is known.
PartitionsNumber of partitions on the physical disk drive that are recognized by the operating system.
PNPDeviceIDPlug and Play device identifier of the logical device.
SCSIBusSCSI bus number of the disk drive.
SCSILogicalUnitSCSI logical unit number (LUN) of the disk drive.
SCSIPortSCSI port number of the disk drive.
SCSITargetIdSCSI identifier number of the disk drive.
SectorsPerTrackNumber of sectors in each track for the physical disk drive.
SignatureUnique identifier for a disk drive.
SizeSize of the disk drive. Disk drive size is calculated by multiplying the total number of cylinders, the tracks in each cylinder, the sectors in each track, and the bytes in each sector.
SystemNameName of the computer where the disk is installed.
TotalCylindersTotal number of cylinders on the physical disk drive.
TotalHeadsTotal number of heads on the disk drive.
TotalSectorsTotal number of sectors on the physical disk drive.
TotalTracksTotal number of tracks on the physical disk drive.
TracksPerCylinderNumber of tracks in each cylinder on the physical disk drive.

Note

  • The values reported for TotalCylinders, TotalHeads, TotalSectors, TotalTracks, and TracksPerCylinder are obtained through extended functions of BIOS interrupt 13h. These values might be inaccurate if the drive uses a translation scheme to support high capacity disk sizes. Consult the manufacturer for accurate drive specifications.

Scripting Steps

Listing 10.1 contains a script that enumerates the properties of all the physical drives installed on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the Windows Management Instrumentation (WMI) namespace root\cimv2, and set the impersonation level to "impersonate."
  3. Use the ExecQuery method to query the Win32_DiskDrive class.

    This query returns a collection consisting of all the disk drives installed on the computer.

  4. For each disk drive in the collection, echo the values of selected drive properties, including DeviceID (drive letter) and partitions, and total cylinders, heads, sectors, and tracks.

    Because the drive capabilities are returned as an array, a For Each loop is used to enumerate each capability.

Listing 10.1   Enumerating Physical Disk Drive Properties

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 
strComputer = "." Set objWMIService = GetObject("winmgmts:" _         & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDiskDrives = objWMIService.ExecQuery _         ("SELECT * FROM Win32_DiskDrive") For each objDiskDrive in colDiskDrives     Wscript.Echo "Bytes Per Sector: " & _         objDiskDrive.BytesPerSector           For Each strCapability in objDiskDrive.Capabilities         Wscript.Echo "Capabilities: " & strCapability     Next         Wscript.Echo "Caption: " & objDiskDrive.Caption     Wscript.Echo "Device ID: " & objDiskDrive.DeviceID     Wscript.Echo "Index: " & objDiskDrive.Index     Wscript.Echo "Interface Type: " & objDiskDrive.InterfaceType     Wscript.Echo "Manufacturer: " & objDiskDrive.Manufacturer     Wscript.Echo "Media Loaded: " & objDiskDrive.MediaLoaded     Wscript.Echo "Media Type: " & objDiskDrive.MediaType     Wscript.Echo "Model: " & objDiskDrive.Model     Wscript.Echo "Name: " & objDiskDrive.Name     Wscript.Echo "Partitions: " & objDiskDrive.Partitions     Wscript.Echo "PNP DeviceID: " & objDiskDrive.PNPDeviceID     Wscript.Echo "SCSI Bus: " & objDiskDrive.SCSIBus     Wscript.Echo "SCSI Logical Unit: " & _         objDiskDrive.SCSILogicalUnit     Wscript.Echo "SCSI Port: " & objDiskDrive.SCSIPort     Wscript.Echo "SCSI TargetId: " & objDiskDrive.SCSITargetId         Wscript.Echo "Sectors Per Track: " & _         objDiskDrive.SectorsPerTrack            Wscript.Echo "Size: " & objDiskDrive.Size            Wscript.Echo "Status: " & objDiskDrive.Status            Wscript.Echo "Total Cylinders: " & _         objDiskDrive.TotalCylinders            Wscript.Echo "Total Heads: " & objDiskDrive.TotalHeads         Wscript.Echo "Total Sectors: " & objDiskDrive.TotalSectors     Wscript.Echo "Total Tracks: " & objDiskDrive.TotalTracks     Wscript.Echo "Tracks Per Cylinder: " & _         objDiskDrive.TracksPerCylinder    Next

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net