WMI command is not returning a current value.

On a set of Windows 2012 servers, i check disk space every day.  

In a vb script, using this statement - (excerpt)

objSWbemServices.ExecQuery _
          ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")

      For Each objDisk in colDisks
           ....
        Next
.......

If Not IsNull(objDisk.FreeSpace) Then
                intVal = CDbl(objDisk.FreeSpace)


Without any changes to my knowledge to server security (using logon account), this vb script would work fine.  So lately within the last few days, (note that the script runs without any error), i can execute it and it creates the WMI object.  But now each day, the hard disk value does not change from day to day.  The intVal value of free disk space stays the same on each day it is run.  Where do I start to analyse?

thanks
LVL 1
Barry LysyApplication Systems Analyst / ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
You need to show more of your code, above does not allow to tell anything, as the lines are not connected, so all we could do is guessing.
0
Shaun VermaakTechnical SpecialistCommented:
Why is
If Not IsNull(objDisk.FreeSpace) Then
                intVal = CDbl(objDisk.FreeSpace)

Open in new window

not in the loop
      For Each objDisk in colDisks
           ....
        Next
.......

Open in new window

?
0
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
I'm canceling this question.  I have  found the root cause. Sorry to be a bother.
0
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

pcelbaCommented:
We are also interested what was the cause.

TIA
0
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
My root cause understanding was incorrect thinking that it was security related.  I tested using a different user's account where that account has local admin priv.  Using that account also returned the same result.  A server reboot looked as though it fixed the issue, but the issue reappeared.  Here is the complete vb script that i use... (also see more comments after the code block.)
----------------------------------------------------------------------
Const HARD_DISK = 3
Dim intVal
Dim strUserName 
Dim strPassword 
Dim strMachineName
Dim objTextFile
Dim strDateTime

Set objFSO = CreateObject("Scripting.FileSystemObject")
strDomain = "" 

strUser = ""
strPassword = ""

strComputer = ""

WScript.Echo strComputer

getDiskSpace strComputer


Sub getDiskSpace(strComputer)
    
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _
                                                     "Root\CIMv2", _
                                                     strUser, _
                                                     strPassword, _
                                                     "MS_409", _
                                                     "ntlmdomain:" + strDomain)
    Set colDisks = objSWbemServices.ExecQuery _
        ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")

   
    For Each objDisk in colDisks

        If Not IsNull(objDisk.FreeSpace) Then
            intVal = CDbl(objDisk.FreeSpace)
            
            strDeviceId = objDisk.DeviceID 
            
            intVal = CDbl(objDisk.FreeSpace / 1024 / 1024)
            
            intVal_2 = intVal* .001
            
            intVal_3 = FormatNumber(intVal_2,3)
            
            WScript.Echo strDeviceId, " ", intVal_3
            
    
     End if
     
    Next

End Sub
-------------------------------------------------------------------------------

 I have been looking into  using WBEMTEST but dont know what to test from within that tool.  Because the script, actually runs and returns free disk space then that suggests permission to use wbem object is fine.  It appears that wbem is an older technology and not much out there for documentation that is current from MS.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
No replys to my latest post.  Please close this question.
0
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
No one has replied so i wish to close this question.
0
Shaun VermaakTechnical SpecialistCommented:
And in your closing answer If Not IsNull(objDisk.FreeSpace) Then is in the loop...
0
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
thank you for your feedback Shaun.  I didnt quite understand what your point is in your remark "Not IsNull(objDisk.FreeSpace) Then is in the loop..."
0
Barry LysyApplication Systems Analyst / ProgrammerAuthor Commented:
What kind of a solution is this??  this is not a solution as it does nothing to fix the issue !!
0
Shaun VermaakTechnical SpecialistCommented:
Your comment is still marked as solution

My comment is not meant to be a solution, only an observation. My point is that you posted broken code with your question, the command is not in the loop, which I queried. In your second comment, the command is in the loop
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.