Where is objRpt defined?  It is giving you an error because you cannot access 
objRpt.VolumeSize because objRpt is null.

Brandon Ryan
Software Engineer | 
[email protected]<mailto:[email protected]>
ClearPointe(r) | 7 Office Park Dr., Suite 200 | Little Rock, AR | 
www.clearpointe.com<http://www.clearpointe.com/>

MANAGED IT SERVICES: Your IT. Our People. 24/7. Guaranteed.

Subscribe to our newsletter: http://www.clearpointe.com/newsletter

This Internet message may contain information that is privileged, confidential, 
and exempt from disclosure. It is intended for use only by the person to whom 
it is addressed. If you have received this in error, please (1) do not forward 
or use this information in any way; and (2) contact me immediately. Neither 
this information block, the typed name of the sender, nor anything else in this 
message is intended to constitute an electronic signature unless a specific 
statement to the contrary is included in this message.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Pete Hakesley
Sent: Friday, October 24, 2014 11:18 AM
To: MSMOM ([email protected])
Subject: [msmom] VBScript SCOM query

Hi all

Been using the various scripting and authoring guides I have a script I am 
working on he get the below values from WMI


...Part of my script...
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colDrives = objWMI.ExecQuery("select Name from Win32_LogicalDisk")

for each strDrive in ColDrives
                strDrive = strDrive.Name
                If ((Mid(strDrive,2,1) <> ":") or (Len(strDrive)> 3)) Then
                                  Exit For
                Else
               set colVols = objWMI.ExecQuery("Select * from Win32_Volume where 
DriveType = 3 And DriveLetter = '" & strDrive & "'")

                                for each objVol in colVols
                                                Set oBag = 
oAPI.CreatePropertyBag()
                                               oBag.AddValue "StatusInstance",  
strDrive
                                                oBag.AddValue "VolumeSize", 
Int(objRpt.VolumeSize / 1073741824) <-- or The script fails at this point
                                                oBag.AddValue "UsedSpace", 
Int(objRpt.UsedSpace / 1073741824) <-- or The script fails at this point
                                                oBag.AddValue "FreeSpace", 
Int(objRpt.FreeSpace / 1073741824) <-- or The script fails at this point
                                                oBag.AddValue 
"FreeSpacePercent", objRpt.FreeSpacePercent <-- or The script fails at this 
point

                                                strVolumeSize = 
objRpt.VolumeSize
                                                strUsedSpace = objRpt.UsedSpace
                                                strFreeSpace = objRpt.FreeSpace
                                                strFreeSpacePercent = 
objRpt.FreeSpacePercent
                                                oAPI.Return(oBag)
                                Next
                End If
Next
...End of part of the script ...

All I keep getting is Object required: " Code 800A01A8 Microsoft VBScript 
runtime error

I think the code is syntactically correct but if anyone can help me - I am at 
the hair pulling stage!


Peter Hakesley | Monitoring & Automation Technical Lead Engineer, Data Centre 
Services

t: +44(0)845 155 6556 ext: 4006
e: [email protected]<mailto:[email protected]> | w: 
www.scc.com<http://www.scc.com/>
a: SCC, CV1, Cole Valley, 20 Westwood Avenue, Tyseley, Birmingham B11 3RZ







Reply via email to