Size of drive

(imported topic written by Braian)

HI All,

any idea on how to get the size of the harddisk? not only the system drive but the actual size of the harddisk installed with or without partions.

Thanks,

Braian

(imported comment written by jgstew)

I recently figured out how to do this using WMI

See the “
Raw Size of SystemDrive
” property of the “
Hard Drive Audit - Windows
” analysis here:
http://bigfix.me/analysis/details/2994701

Also see the related and supplementary “
Hard Drive Audit - Universal
” analysis here:
http://bigfix.me/analysis/details/2994572

(imported comment written by Braian)

Hi jgstew,

Thanks for the link, this work for most of our workstation but some reported as “Singular expression refers to nonexistent object.” i have notice that there are two property “size” w/ value and the other is without value. how can i edit the analysis to eliminate the error “Singular expression refers to nonexistent object.” and get the value of the size property. I’m not sure if there is USB connected.

here is the properties of win32_drive from a workstation with error:

Availability

BytesPerSector=512

Capabilities

CapabilityDescriptions

Caption=WDC WD5000AAKX-08ERMA0

CompressionMethod

ConfigManagerErrorCode=0

ConfigManagerUserConfig=False

CreationClassName=Win32_DiskDrive

DefaultBlockSize

Description=Disk drive

DeviceID=\.\PHYSICALDRIVE0

ErrorCleared

ErrorDescription

ErrorMethodology

FirmwareRevision=19.0

Index=0

InstallDate

InterfaceType=IDE

LastErrorCode

Manufacturer=(Standard disk drives)

MaxBlockSize

MaxMediaSize

MediaLoaded=True

MediaType=Fixed hard disk media

MinBlockSize

Model=WDC WD5000AAKX-08ERMA0

Name=\.\PHYSICALDRIVE0

NeedsCleaning

NumberOfMediaSupported

Partitions=3

PNPDeviceID=IDE\DISKWDC_WD5000AAKX-08ERMA0__________________19.01H19\4&58D88E5&0&0.0.0

PowerManagementCapabilities

PowerManagementSupported

SCSIBus=0

SCSILogicalUnit=0

SCSIPort=0

SCSITargetId=0

SectorsPerTrack=63

SerialNumber= W -DCW2CEE2T3327

Signature=-1361873989

Size=500105249280

Status=OK

StatusInfo

SystemCreationClassName=Win32_ComputerSystem

SystemName=CORORT-D0049

TotalCylinders=60801

TotalHeads=255

TotalSectors=976768065

TotalTracks=15504255

TracksPerCylinder=255

Availability

BytesPerSector

Capabilities

CapabilityDescriptions

Caption=SEMC Mass Storage USB Device

CompressionMethod

ConfigManagerErrorCode=0

ConfigManagerUserConfig=False

CreationClassName=Win32_DiskDrive

DefaultBlockSize

Description=Disk drive

DeviceID=\.\PHYSICALDRIVE1

ErrorCleared

ErrorDescription

ErrorMethodology

FirmwareRevision=0100

Index=1

InstallDate

InterfaceType=USB

LastErrorCode

Manufacturer=(Standard disk drives)

MaxBlockSize

MaxMediaSize

MediaLoaded=True

MediaType

MinBlockSize

Model=SEMC Mass Storage USB Device

Name=\.\PHYSICALDRIVE1

NeedsCleaning

NumberOfMediaSupported

Partitions=0

PNPDeviceID=USBSTOR\DISK&VEN_SEMC&PROD_MASS_STORAGE&REV_0100\43423541314A41344830&0

PowerManagementCapabilities

PowerManagementSupported

SCSIBus

SCSILogicalUnit

SCSIPort

SCSITargetId

SectorsPerTrack

SerialNumber=43423541314A41344830

Signature=0

Size

Status=OK

StatusInfo

SystemCreationClassName=Win32_ComputerSystem

SystemName=CORORT-D0049

TotalCylinders

TotalHeads

TotalSectors

TotalTracks

TracksPerCylinder

(imported comment written by jgstew)

The property should not result in an error as written based upon the result you listed.

The machine you are saying gives an error has 2 dives in it, the system drive and a USB drive. The USB drive does not report a size, but it looks like the system drive does. The property only tries to get the size of the disk at index 0, which does appear to have a proper size, so I’m not sure why there is an error in this case.

It might be possible to do something to the WMI query. Try this:

((it as integer) of string values of selects "Size from Win32_DiskDrive WHERE Index=0 AND size!=’’ " of wmi)

(imported comment written by jgstew)

Actually, it might be the case that “Index=0” does not always indicate the system drive. I see 1 system in our environment that has a ZIP drive that appears to be reporting as Index=0

(imported comment written by Braian)

hi jgstew,

thanks again for the help, as i have notice the error is gone but the workstation with 2 physical hdd will only report 1 value instead of multiple result.thanks

(imported comment written by jgstew)

If you wanted to get all sizes of all drives with sizes instead of just the size of the drive at index=0, then try this:

((it as integer) of string values of selects "Size from Win32_DiskDrive WHERE size!=’’ " of wmi)

I have updated the analysis I referenced above to include the check for size!=’’ (
http://bigfix.me/analysis/details/2994706
)

(imported comment written by Braian)

thanks jgstew, ihave tried this analysis and have an error, i am also trying to edit the analysis. please post for any suggestion.

if (exists wmi) then ((string value of property “size” of it as integer / 1024/1024/1024) as string & " GB") of (select objects "Size from Win32_DiskDrive WHERE size!=’’ " of wmi) else nothings

result is:

465 GB

singular expression refers to nonexistent object.

(imported comment written by jgstew)

Try:

if (exists wmi) then (((string value of property “size” of it as integer / 1024/1024/1024) as string & " GB") of (select objects "Size from Win32_DiskDrive WHERE size!=’’ " of wmi) whose(exists property “size” of it)) else nothings

(imported comment written by Braian)

same error jgstew. thanks