This script demonstrates how the current health of an SMS site can be determined from summary information available from the SMS Provider. The health is a summary of SMS sites, components, packages, and advertisements. The status can be one of the three values described in the following table.

Status Description

0

Healthy—There are no warning or error messages.

1

Warning—There are warning messages (but no error messages), or a threshold is approaching its limit.

2

Critical—There are error messages, or a threshold has been exceeded.

The following example works by inspecting the WMI class SMS_SummarizerSiteStatus. There is an instance of this class for each site within the SMS site hierarchy. This example displays the site code of each site and the current status for that site.

For additional information about using summarizers to determine the health of a site, see the SMS 2003 SDK.

Example

On Error Resume Next
Dim objSWbemServices
Dim ProviderLoc
Dim Location
Dim strSummarizerSiteStatus
Dim colSummarizerSiteStatus
Dim objSiteSummary

strSummarizerSiteStatus="SMS_SummarizerSiteStatus"
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

'Get SMS_SummarizerSiteStatus. 
Set colSummarizerSiteStatus=objSWbemServices.InstancesOf(strSummarizerSiteStatus)

If err.number<>0 Then
	wscript.echo "Couldn't get Site Summary"
	wscript.quit
End If

For Each objSiteSummary In colSUmmarizerSiteStatus
	wscript.echo "Site code:" + objSiteSummary.SiteCode
	If objSiteSummary.Status=0 Then
		wscript.echo "Site is healthy"
	End If
	If objSiteSummary.Status=1 Then
	wscript.echo "There are warnings for this site"
	End If
	If objSiteSummary.Status=2 Then
		wscript.echo "The site health is critical"
	End If
Next

Compiling the Code

  • Requires Windows 2000 Server SP2 or later.

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

See Also