Kaseya Community

WMI Syntax?

This question is answered

Trying to find a way to create a variable for freespace on a disk, then have the variable checked for a minimum amount of diskspace.

I am TRYING to use Get Variable > WMI Property with the string of: root\cimv2:Win32_LogicalDisk[C:].FreeSpace

But this step keeps erroring out. I am attempting to follow the syntax laid down in the help file, but am I missing something?

[edited by: tlctech at 2:35 PM (GMT -8) on 12-21-2010] Spelling corrected
Verified Answer
  • yes you have to use numbers it does not understand letters, think of it as an old style array

All Replies
  • (From the help file)

    WMI Property - A WMI namespace, class, and property. The format of the specified WMI property is NameSpace:Class.Property. For example, root\cimv2:Win32_OperatingSystem.FreePhysicalMemory. Specify an instance using the following syntax: NameSpace:Class[ N ].Property where [ N ] is the instance number. For example, root\cimv2:Win32_OnboardDevice[3].Description. The first instance may be specified with or without specifying the [1] instance number.

    [edited by: HardKnoX at 4:21 PM (GMT -8) on 12-21-2010] Typo
  • Here is an example;


    Note that the instance number could be anything from 1 to 3 for C drive has it will depend on if the computer has an A and/or B drives installed so if you want to script this you would want to find out if drive A and drive B exists.


    Also it would be good to learn how to get these values via WMIC because that what I used to help you with your problem, you could also use a WMI browser if you are GUI inclined.

    [edited by: HardKnoX at 4:30 PM (GMT -8) on 12-21-2010] Typo
  • Yup, I read that, hence the string above. :D

    In WMI explorer, the instance for the C drive is C: and not a number.

    Unless I am suppossed to substitute the instance of c with a number.

  • yes you have to use numbers it does not understand letters, think of it as an old style array

  • Worked like a charm.

    Thanx for your help.