How to Query SMS Component Status for a Specified Interval

Published : April 11, 2005

During troubleshooting and for overall health maintenance of an SMS site, it is useful to get a summary of the error and warning messages generated by the various SMS components over time. An instance of the SMS Provider class SMS_ComponentSummarizer exists for a variety of time intervals for each component.

The time intervals summarized range from 12.00 A.M. today to the time the site was first installed. The interval is a numeric string known as the Tally Interval, and the complete set is documented in the SMS 2003 SDK.

In this example, a WQL Query queries the SMS Provider, via SMS_ComponentSummarizer, for a summary of each component since the site was first installed. When retrieved by ExecQuery, the name, error, and warning messages for each component are displayed.

On This Page

Example
Compiling the Code
See Also

Example

On Error Resume Next
 
Dim objSWbemServices
Dim ProviderLoc
Dim Location
Dim objQuery
Dim colQueryComponentResults
Dim objResult
 
Set ProviderLoc = GetObject("winmgmts:{impersonationLevel=impersonate}!root/sms:SMS_ProviderLocation")
 
If err.number<>0 Then
    wscript.echo "Couldn't get SMS Provider"
    wscript.quit
End If
 
For Each Location In ProviderLoc.Instances_
     If Location.ProviderForLocalSite = True Then
        Set objSWbemServices = GetObject("winmgmts:" & Location.NamespacePath)
        Exit For
    End If
Next
'Query components since site installation.
Set colQueryComponentResults=objSWbemServices.ExecQuery("SELECT * FROM SMS_ComponentSummarizer WHERE TallyInterval='0001128000080008'" )
 
If err.number<>0 Then
    wscript.echo "Couldn't get components"
    wscript.quit
End If
'Run query.
wscript.echo "Components"
wscript.echo "----------------------------------"
For Each objResult In colQueryComponentResults
    wscript.echo "Name      " + objResult.ComponentName
    wscript.echo "Errors    " +cstr(objResult.Errors )
    wscript.echo "Warnings  " + cstr (objResult.Warnings)
Next
If colQueryComponentResults.Count=0 Then
    wscript.echo "      no query results"
End If

Compiling the Code

  • Requires Windows 2000 Server SP2 or later.

  • You must run this sample on an SMS 2003 primary site server.

See Also

Tasks

How to Query SMS Site Status for a Specified Interval

How to Read SMS Objects

How to Summarize an SMS Site's Health