Export (0) Print
Expand All

Managing and Monitoring Disk Drives

Microsoft® Windows® 2000 Scripting Guide

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

Property

Description

BytesPerSector

Number of bytes in each sector for the physical disk drive.

Capabilities

Array 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

CompressionMethod

Algorithm or tool used by the device to support compression.

Description

Description of the disk drive.

DeviceID

Unique identifier of the disk drive with other devices on the system.

Index

Physical drive number of the given drive. A value of 0xFF indicates that the given drive does not map to a physical drive.

InterfaceType

Interface type of physical disk drive, typically IDE or SCSI.

Manufacturer

Name of the disk drive manufacturer.

MediaType

Type of media used or accessed by this device. Values are:

  • Removable media

  • Fixed hard disk

  • Unknown

Model

Manufacturer's model number of the disk drive.

Name

Label by which the disk drive is known.

Partitions

Number of partitions on the physical disk drive that are recognized by the operating system.

PNPDeviceID

Plug and Play device identifier of the logical device.

SCSIBus

SCSI bus number of the disk drive.

SCSILogicalUnit

SCSI logical unit number (LUN) of the disk drive.

SCSIPort

SCSI port number of the disk drive.

SCSITargetId

SCSI identifier number of the disk drive.

SectorsPerTrack

Number of sectors in each track for the physical disk drive.

Signature

Unique identifier for a disk drive.

Size

Size 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.

SystemName

Name of the computer where the disk is installed.

TotalCylinders

Total number of cylinders on the physical disk drive.

TotalHeads

Total number of heads on the disk drive.

TotalSectors

Total number of sectors on the physical disk drive.

TotalTracks

Total number of tracks on the physical disk drive.

TracksPerCylinder

Number of tracks in each cylinder on the physical disk drive.

note 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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft