Jump to content

Understanding WMI and SoftwareLicensingProduct Class


Recommended Posts

Currently I have the following

Dim $strcomputer = "."

Dim $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strcomputer & "\root\cimv2")
Dim $colSettings = $objWMIService.ExecQuery ("SELECT * FROM SoftwareLicensingProduct")

For $objComputer in $colSettings
    $LicenseStatus = $objComputer.LicenseStatus
    $EvaluationendDate = _WMIDateStringToDate($objComputer.EvaluationendDate)
    $GracePeriodRemaining = $objComputer.GracePeriodRemaining
Next

See http://msdn.microsoft.com/en-us/library/cc534596(VS.85).aspx for SoftwareLicensingProduct Class

Ignore the fact that it's missing _WMIDateStringToDate for now the important part that I'm stuck on is the value returned for GracePeriodRemaining.

I know that what is currently held on the PC in WMI for GracePeriodRemaining is the following.

0

35940

0

0

0

0

0

What is being returned in the code above for GracePeriodRemaining is 0.

Is this because the query is only returning the first row?

How to I access different rows? I've had a read on the beginners WMI thread but can't see what I'm after.

Any pointers would be greatly received.

Link to comment
Share on other sites

Ok using Scriptomatic I've now got

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$Output = ""

For $objItem In $colItems
    $Output = $objItem.GracePeriodRemaining
    If $Output <> 0 then ExitLoop
Next

Msgbox(48,"WMI Output",$Output)

This now returns 35940 which is the value I was after.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...