SMS 2003 Service Discovery - Server

SMS_2003_Service_Discovery___Server (WriteActionModuleType)

Performs Service Discovery for SMS servers

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{1FAAF124-613B-4D22-8D24-A88AD9119E23}

Member Modules:

ID Module Type TypeId RunAs 
RunScriptAction WriteAction System.Mom.BackwardCompatibility.ScriptResponse Default

Source Code:

<WriteActionModuleType ID="SMS_2003_Service_Discovery___Server" Accessibility="Internal" Comment="{1FAAF124-613B-4D22-8D24-A88AD9119E23}">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>MomBackwardCompatibility!System.Mom.BackwardCompatibility.AlertGenerationSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AlertGeneration" type="AlertGenerationType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InvokerType" type="xsd:integer"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="RunScriptAction" TypeID="MomBackwardCompatibility!System.Mom.BackwardCompatibility.ScriptResponse">
<AlertGeneration>$Config/AlertGeneration$</AlertGeneration>
<InvokerType>$Config/InvokerType$</InvokerType>
<Body><Script>
'*******************************************************************************
' Script Name - SMS 2003 Service Discovery - Server
'
' Purpose - Performs service discovery functions on SMS 2003 Servers.
'
' Assumptions - This script will only run on SMS 2003 Servers.
'
' Parameters - None
'
' Change Hist - Date Version Description
' -------- --------------- -----------
' 02/15/04 02.50.0161.0000 Created
' 04/08/04 02.50.0174.0000 Update for new state monitoring
' component support.
' 05/08/04 02.50.0178.0000 Added topology diagram shape
' annotations. Replaced AttributeValue_
' MicrosoftSMS2003SQLMonitorService with
' AttributeValue_MicrosoftSMS2003SQLServer
' and updated computer group formula for
' Microsoft SMS 2003 Site Database Servers.
' 06/02/04 05.0.2702.0000 Added Reporting Points and Server
' Locator Points to method
' InComputerGroup_MicrosoftSMS2003Servers.
' Removed version check from method
' InComputerGroup_
' MicrosoftSMS2003DistributionPointServers.
' 02/20/07 05.0.3132.0000 Added check for SMS 2003 version to the
' following computer group functions.
'
' InComputerGroup_MicrosoftSMS2003CentralSiteServers
' InComputerGroup_MicrosoftSMS2003DistributionPointServers
' InComputerGroup_MicrosoftSMS2003ManagementPointServers
' InComputerGroup_MicrosoftSMS2003ReportingPointServers
' InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers
'
' (c) Copyright 2007, Microsoft Corp., All Rights Reserved
'*******************************************************************************

Option Explicit

'Event Severity Constants
'========================

Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

Const EVENTLOG_AUDIT_SUCCESS = 8
Const EVENTLOG_AUDIT_FAILURE = 16


'Event Number Constants
'======================

Const EVENT_ID_NOTANEVENT = 1100
Const EVENT_ID_SCRIPTSUCCESS = 1101
Const EVENT_ID_SCRIPTERROR = 1102
Const EVENT_ID_ACCESSDENIED = 1105


'Event and Log Messages Constants
'================================

'Start Localization
Const WMI_NO_NAMESPACE_SOURCE = "Unable to open WMI Namespace {Namespace}"
Const WMI_NO_NAMESPACE_DESCRIPTION = "Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists. Error:{ErrorNumber}, {ErrorDescription}."

Const WMI_NO_INSTANCES_SOURCE = "The class name '{ClassName}' returned no instances."
Const WMI_NO_INSTANCES_DESCRIPTION = "Please check to see if this is a valid WMI class name. Error:{ErrorNumber}, {ErrorDescription}."

Const WMI_NO_VALID_INSTANCES_SOURCE = "The class name '{ClassName}' did not return any valid instances."
Const WMI_NO_VALID_INSTANCES_DESCRIPTION = "Please check to see if this is a valid WMI class name. Error:{ErrorNumber}, {ErrorDescription}."

Const WMI_QUERY_NO_RESULTS_SOURCE = "The Query '{Query}' returned an invalid result set."
Const WMI_QUERY_NO_RESULTS_DESCRIPTION = "Please check to see if this is a valid WMI Query. Error:{ErrorNumber}, {ErrorDescription}."

Const WMI_QUERY_NO_VALID_INSTANCES_SOURCE = "The Query '{Query}' did not return any valid instances."
Const WMI_QUERY_NO_VALID_INSTANCES_DESCRIPTION = "Please check to see if this is a valid WMI Query. Error:{ErrorNumber}, {ErrorDescription}."
'End Localization


'Discovery Constants
'===================

Const DISCOVERY_SCOPE_ID = "{9D7099DA-6F9C-44C1-9EF5-BBF19C423BF5}" 'Rule GUID or the PR that runs this script

Const COMPUTER_CLASS_ID = "Computer"
Const COMPUTER_COMPUTER_NAME_ATTRIBUTE_ID = "ComputerName"
Const COMPUTER_TIME_ZONE_BIAS_ATTRIBUTE_ID = "Time Zone Bias"
Const COMPUTER_OPERATING_SYSTEM_VERSION_ATTRIBUTE_ID = "Operating System Version"
Const COMPUTER_IP_ADDRESS_ATTRIBUTE_ID = "IPAddress"
Const COMPUTER_FQDN_ATTRIBUTE_ID = "FQDN"

Const SMS_SERVER_CLASS_ID = "SMS Server"
Const SMS_SERVER_NAME_ATTRIBUTE_ID = "Name"
Const SMS_SERVER_COMPONENTS_ATTRIBUTE_ID = "Components"
Const SMS_SERVER_VERSION_ATTRIBUTE_ID = "Version"
Const SMS_SERVER_SITE_CODE_ATTRIBUTE_ID = "Site Code"
Const SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID = "Server Type"
Const SMS_SERVER_SHAPE_ANNOTATION_2_ATTRIBUTE_ID = "Site System Type"
Const SMS_SERVER_SHAPE_ANNOTATION_3_ATTRIBUTE_ID = "Database Server Type"
Const SMS_SERVER_CLIENT_ACCESS_POINT_COMPONENT_ID = "CAP"
Const SMS_SERVER_SITE_DATABASE_COMPONENT_ID = "DB"
Const SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID = "DP"
Const SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID = "MP"
Const SMS_SERVER_PROVIDER_COMPONENT_ID = "Provider"
Const SMS_SERVER_REPORTING_POINT_COMPONENT_ID = "RP"
Const SMS_SERVER_SENDER_COMPONENT_ID = "Sender"
Const SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID = "SLP"
Const SMS_SERVER_SITE_SERVER_COMPONENT_ID = "SS"
Const SMS_SERVER_PERFORMANCE_COMPONENT_ID = "Performance"

Const SMS_SERVER_SHAPE_ANNOTATION_1_CENTRAL_SITE = "Central Site"
Const SMS_SERVER_SHAPE_ANNOTATION_1_PRIMARY_SITE = "Primary Site"
Const SMS_SERVER_SHAPE_ANNOTATION_1_SECONDARY_SITE = "Secondary Site"
Const SMS_SERVER_SHAPE_ANNOTATION_1_SITE_SYSTEM = "Site System"

Const SMS_SERVER_SHAPE_ANNOTATION_2_MANAGEMENT_POINT = "Management Point"

Const SMS_SERVER_SHAPE_ANNOTATION_3_SITE_DATABASE = "Site Database"


'Other constants
'===============

Const SCRIPT_NAME = "SMS 2003 Service Discovery - Server"


' Global variables
'=================

Dim g_oUtil ' Utility class for MOM events, logging and registry access.


'******************************************************************************
' Replacement string functions for event and log messages
'
'

Function GET_WMI_NO_NAMESPACE_SOURCE(ByVal sNamespace)
GET_WMI_NO_NAMESPACE_SOURCE = Replace(WMI_NO_NAMESPACE_SOURCE, "{Namespace}", sNamespace)
End Function

Function GET_WMI_NO_NAMESPACE_DESCRIPTION(ByVal lErrorNumber, ByVal sErrorDescription)
Dim sResult
sResult = Replace(WMI_NO_NAMESPACE_DESCRIPTION, "{ErrorNumber}", lErrorNumber)
GET_WMI_NO_NAMESPACE_DESCRIPTION = Replace(sResult, "{ErrorDescription}", sErrorDescription)
End Function

Function GET_WMI_NO_INSTANCES_SOURCE(ByVal sClassName)
GET_WMI_NO_INSTANCES_SOURCE = Replace(WMI_NO_INSTANCES_SOURCE, "{ClassName}", sClassName)
End Function

Function GET_WMI_NO_INSTANCES_DESCRIPTION(ByVal lErrorNumber, ByVal sErrorDescription)
Dim sResult
sResult = Replace(WMI_NO_INSTANCES_DESCRIPTION, "{ErrorNumber}", lErrorNumber)
GET_WMI_NO_INSTANCES_DESCRIPTION = Replace(sResult, "{ErrorDescription}", sErrorDescription)
End Function

Function GET_WMI_NO_VALID_INSTANCES_SOURCE(ByVal sClassName)
GET_WMI_NO_VALID_INSTANCES_SOURCE = Replace(WMI_NO_VALID_INSTANCES_SOURCE, "{ClassName}", sClassName)
End Function

Function GET_WMI_NO_VALID_INSTANCES_DESCRIPTION(ByVal lErrorNumber, ByVal sErrorDescription)
Dim sResult
sResult = Replace(WMI_NO_VALID_INSTANCES_DESCRIPTION, "{ErrorNumber}", lErrorNumber)
GET_WMI_NO_VALID_INSTANCES_DESCRIPTION = Replace(sResult, "{ErrorDescription}", sErrorDescription)
End Function

Function GET_WMI_QUERY_NO_RESULTS_SOURCE(ByVal sQuery)
GET_WMI_QUERY_NO_RESULTS_SOURCE = Replace(WMI_QUERY_NO_RESULTS_SOURCE, "{Query}", sQuery)
End Function

Function GET_WMI_QUERY_NO_RESULTS_DESCRIPTION(ByVal lErrorNumber, ByVal sErrorDescription)
Dim sResult
sResult = Replace(WMI_QUERY_NO_RESULTS_DESCRIPTION, "{ErrorNumber}", lErrorNumber)
GET_WMI_QUERY_NO_RESULTS_DESCRIPTION = Replace(sResult, "{ErrorDescription}", sErrorDescription)
End Function

Function GET_WMI_QUERY_NO_VALID_INSTANCES_DESCRIPTION(ByVal lErrorNumber, ByVal sErrorDescription)
Dim sResult
sResult = Replace(WMI_QUERY_NO_VALID_INSTANCES_DESCRIPTION, "{ErrorNumber}", lErrorNumber)
GET_WMI_QUERY_NO_VALID_INSTANCES_DESCRIPTION = Replace(sResult, "{ErrorDescription}", sErrorDescription)
End Function

Function GET_WMI_QUERY_NO_VALID_INSTANCES_SOURCE(ByVal sQuery)
GET_WMI_QUERY_NO_VALID_INSTANCES_SOURCE = Replace(WMI_QUERY_NO_VALID_INSTANCES_SOURCE, "{Query}", sQuery)
End Function

'******************************************************************************
' Name: Main
'
' Purpose: Entry point for program execution.
'
' Parameters: None
'
' Returns: Nothing
'
' Remarks: This routine will manage its error return.
'
Sub Main()

On Error Resume Next

'Initialize utility object and begin tracing.
'============================================

Set g_oUtil = new Util

Call g_oUtil.SetDebugLevel(g_oUtil.DBG_TRACE)

Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, " " + SCRIPT_NAME + " script starting at local time: " + CStr(Time))

'WMI is used by discovery functions in this script so check that it is
'accessible.
'=====================================================================

If True &lt;&gt; IsWMIAccessible() Then
Set g_oUtil = Nothing
Exit Sub
End if

'Perform service discovery.
'==========================

DoServiceDiscovery

Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, " " + SCRIPT_NAME + " script completed at local time: " + CStr(Time))

Set g_oUtil = Nothing

End Sub

'******************************************************************************
' Name: IsWMIAccessible
'
' Purpose: To determine whether the WMI service is running and accessible
'
' Parameters: None
'
' Returns: Boolean, returns True if the WMI service and root\default namespace
' is accessible.
'
' Remarks: If an error is encountered this function will throw an exception
' the caller MUST handle this.
'
Function IsWMIAccessible()

Dim objService


On Error Resume Next

Err.Clear


Set objService = GetObject("winmgmts:\\" + ScriptContext.TargetComputer + "\root\default")

If Err Then
IsWMIAccessible = False
Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "WMI Access Failure, Error #: " + CStr(Err.Number) + ", Description: " + Err.Description)
Else
IsWMIAccessible = True
End If

End Function

'******************************************************************************
' Name: DoServiceDiscovery
'
' Purpose: Performs all discovery service functions.
'
' Parameters: None
'
' Returns: Nothing
'
' Remarks: This routine will manage its error return.
'
Sub DoServiceDiscovery

Dim oDiscData

'Create Discovery Data object.
'=============================

Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "Creating DiscoveryData packet." )

Set oDiscData = ScriptContext.CreateDiscoveryData()

oDiscData.ScopeID = DISCOVERY_SCOPE_ID

'Initialize Discovery Data object for the SMS class.
'===================================================

Initialize oDiscData

'Submit the Discovery Data object.
'=================================

Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "Submitting Discovery data packet.")

ScriptContext.Submit oDiscData

End Sub

'******************************************************************************
' Name: Initialize
'
' Purpose: Initializes Discovery Data object for appropriate SMS class(es).
'
' Parameters: ByVal oDiscData Discovery Data oject returned by
' ScriptContext.CreateDiscoveryData().
'
' Returns: Nothing
'
' Remarks: This routine will manage its error return.
'
Sub Initialize(ByVal oDiscData)

Dim oSMSServer
Dim oCollection
Dim oInstance

Dim strSMSComponents


'Initialize SMSServer object for accessing SMS Server data.
'==========================================================

Set oSMSServer = new SMSServer

'Specify the discovery scope for class components (subgroups or functions)
'and properties of the class.
'=========================================================================

Set oCollection = oDiscData.CreateCollection()

With oCollection
.ClassID = SMS_SERVER_CLASS_ID
.AddScopeFilter COMPUTER_COMPUTER_NAME_ATTRIBUTE_ID, ScriptContext.TargetComputerIdentity
.AddScopeComponent SMS_SERVER_CLIENT_ACCESS_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SITE_DATABASE_COMPONENT_ID
.AddScopeComponent SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_PROVIDER_COMPONENT_ID
.AddScopeComponent SMS_SERVER_REPORTING_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SENDER_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SITE_SERVER_COMPONENT_ID
.AddScopeComponent SMS_SERVER_PERFORMANCE_COMPONENT_ID
' .AddScopeProperty SMS_SERVER_NAME_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_COMPONENTS_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_VERSION_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_SITE_CODE_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_SHAPE_ANNOTATION_2_ATTRIBUTE_ID
.AddScopeProperty SMS_SERVER_SHAPE_ANNOTATION_3_ATTRIBUTE_ID
End With

'Create and initialize instances of the class based on components and
'and properties present.
'====================================================================

Set oInstance = oCollection.CreateInstance()

If oSMSServer.InComputerGroup_MicrosoftSMS2003ClientAccessPointServers() Then

oInstance.AddComponent SMS_SERVER_CLIENT_ACCESS_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_CLIENT_ACCESS_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_CLIENT_ACCESS_POINT_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003SiteDatabaseServers() Then

oInstance.AddComponent SMS_SERVER_SITE_DATABASE_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_SITE_DATABASE_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_SITE_DATABASE_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003DistributionPointServers() Then

oInstance.AddComponent SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003ManagementPointServers() Then

oInstance.AddComponent SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003Providers() Then

oInstance.AddComponent SMS_SERVER_PROVIDER_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_PROVIDER_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_PROVIDER_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003ReportingPointServers() Then

oInstance.AddComponent SMS_SERVER_REPORTING_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_REPORTING_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_REPORTING_POINT_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003SenderServers() Then

oInstance.AddComponent SMS_SERVER_SENDER_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_SENDER_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_SENDER_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers() Then

oInstance.AddComponent SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID
End If

End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003SiteServers() Then

oInstance.AddComponent SMS_SERVER_SITE_SERVER_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_SITE_SERVER_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_SITE_SERVER_COMPONENT_ID
End If

End If

oInstance.AddComponent SMS_SERVER_PERFORMANCE_COMPONENT_ID

oInstance.AddKeyProperty SMS_SERVER_NAME_ATTRIBUTE_ID, ScriptContext.TargetNetbiosComputer
oInstance.AddProperty SMS_SERVER_COMPONENTS_ATTRIBUTE_ID, strSMSComponents
oInstance.AddProperty SMS_SERVER_VERSION_ATTRIBUTE_ID, oSMSServer.GetSMSVersion()
oInstance.AddProperty SMS_SERVER_SITE_CODE_ATTRIBUTE_ID, oSMSServer.GetSMSSiteCode()

If oSMSServer.InComputerGroup_MicrosoftSMS2003CentralSiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_CENTRAL_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMS2003PrimarySiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_PRIMARY_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMS2003SecondarySiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_SECONDARY_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMS2003ClientAccessPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMS2003DistributionPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMS2003ReportingPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMS2003SenderServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_SITE_SYSTEM
End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003ManagementPointServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_2_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_2_MANAGEMENT_POINT
End If

If oSMSServer.InComputerGroup_MicrosoftSMS2003SiteDatabaseServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_3_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_3_SITE_DATABASE
End If

oCollection.AddInstance oInstance
oDiscData.AddCollection oCollection

Set oSMSServer = Nothing

End Sub

'==========================================================================
' Class: SMSServer
' Description: Provides key property information about an SMS Server.
'==========================================================================
Class SMSServer
'---------------
' Properties and Constants (Initialized on constructor due to VBS behavior)
'---------------

Public SMS2003_MIN_VERSION

'---------------
' Methods
'---------------

'=============
' Method: Class_Initialize
' Description: This is the constructor
' Parameters:
'=============
Private Sub Class_Initialize()

SMS2003_MIN_VERSION = "2.5.0000.0000"

End Sub

'=============
' Method: Class_Terminate
' Description: This is the destructor
' Parameters:
'=============
Private Sub Class_Terminate()
End Sub

'=============
' Method: GetSMSVersion
'
' Description: Get the SMS Version from the registry.
'
' Parameters: None
'
' Returns: A string if successful otherwise empty.
'=============
Public Function GetSMSVersion()

Dim strVersion


strVersion = AttributeValue_MicrosoftSMS2003HighestVersionNumber()

If IsEmpty(strVersion) Then
strVersion = AttributeValue_MicrosoftSMS2003SiteServerVersionNumber()
End If

GetSMSVersion = strVersion

End Function

'=============
' Method: GetSMSSiteCode
'
' Description: Get the SMS Site Code from the registry.
'
' Parameters: None
'
' Returns: A string if successful otherwise empty.
'=============
Public Function GetSMSSiteCode()

Dim strSiteCode


strSiteCode = g_oUtil.ReadRegistryStringValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPERATIONS_MANAGEMENT, g_oUtil.REG_VALUE_SMS_SERVER_SITE_CODE)

If IsEmpty(strSiteCode) Then
strSiteCode = AttributeValue_MicrosoftSMS2003SiteCode()
End If

GetSMSSiteCode = strSiteCode

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003CentralSiteServers
'
' Description: "Microsoft SMS 2003 Central Site Servers" computer
' group. SMS 2003 site servers that are central site
' servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003CentralSiteServers()

If AttributeValue_MicrosoftSMS2003CentralSiteServer() = 1 And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003CentralSiteServers = True
Else
InComputerGroup_MicrosoftSMS2003CentralSiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ClientAccessPointServers
'
' Description: "Microsoft SMS 2003 Client Access Point Servers"
' computer group. SMS 2003 site servers or site systems
' that are Client Access Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ClientAccessPointServers()

If AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003InboxManagerAssistant() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003ClientAccessPointServers = True
Else
InComputerGroup_MicrosoftSMS2003ClientAccessPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ComponentServersbasedonSMSExecutive
'
' Description: "Microsoft SMS 2003 Component Servers based on
' SMS Executive" computer group. SMS 2003 site servers
' or site systems running the SMS Executive service.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ComponentServersbasedonSMSExecutive()

If AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003ComponentServersbasedonSMSExecutive = True
Else
InComputerGroup_MicrosoftSMS2003ComponentServersbasedonSMSExecutive = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003DistributionPointServers
'
' Description: "Microsoft SMS 2003 Distribution Point Servers"
' computer group. SMS 2003 site server or site systems
' that are Distribution Point servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003DistributionPointServers()

If AttributeValue_MicrosoftSMS2003DistributionPoint() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003DistributionPointServers = True
Else
InComputerGroup_MicrosoftSMS2003DistributionPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ManagementPointServers
'
' Description: "Microsoft SMS 2003 Management Point Servers" computer
' group. SMS 2003 site servers or site systems that are
' Management Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ManagementPointServers()

If AttributeValue_MicrosoftSMS2003AgentHostService() And _
AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003ManagementPointControlManager() And _
AttributeValue_MicrosoftSMS2003ManagementPointFileDispatchManager() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003ManagementPointServers = True
Else
InComputerGroup_MicrosoftSMS2003ManagementPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003PrimarySiteServers
'
' Description: "Microsoft SMS 2003 Primary Site Servers" computer
' group. SMS 2003 site servers that are primary site
' servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003PrimarySiteServers()

If AttributeValue_MicrosoftSMS2003SiteServerType() = 1 And _
AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003SiteServerVersionNumber() &gt; SMS2003_MIN_VERSION And _
Len(AttributeValue_MicrosoftSMS2003SiteCode()) = 3 Then
InComputerGroup_MicrosoftSMS2003PrimarySiteServers = True
Else
InComputerGroup_MicrosoftSMS2003PrimarySiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003Providers
'
' Description: "Microsoft SMS 2003 Providers" computer group.
' SMS 2003 site servers or site database servers that
' are SMS Providers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003Providers()

If AttributeValue_MicrosoftSMS2003Provider() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003Providers = True
Else
InComputerGroup_MicrosoftSMS2003Providers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ReportingPointServers
'
' Description: "Microsoft SMS 2003 Reporting Point Servers" computer
' group. SMS 2003 site server or site systems that are
' Reporting Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ReportingPointServers()

If AttributeValue_MicrosoftSMS2003ReportingPointService() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003ReportingPointServers = True
Else
InComputerGroup_MicrosoftSMS2003ReportingPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003SecondarySiteServers
'
' Description: "Microsoft SMS 2003 Secondary Site Servers" computer
' group. SMS 2003 site servers that are secondary site
' servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003SecondarySiteServers()

If AttributeValue_MicrosoftSMS2003SiteServerType() = 2 And _
AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003SiteServerVersionNumber() &gt; SMS2003_MIN_VERSION And _
Len(AttributeValue_MicrosoftSMS2003SiteCode()) = 3 Then
InComputerGroup_MicrosoftSMS2003SecondarySiteServers = True
Else
InComputerGroup_MicrosoftSMS2003SecondarySiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003SenderServers
'
' Description: "Microsoft SMS 2003 Sender Servers" computer group.
' SMS 2003 site servers or site systems that are Client
' Access Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003SenderServers()

If AttributeValue_MicrosoftSMS2003ExecutiveService() And _
AttributeValue_MicrosoftSMS2003LANSender() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003SenderServers = True
Else
InComputerGroup_MicrosoftSMS2003SenderServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers
'
' Description: "Microsoft SMS 2003 Server Locator Point Servers" computer
' group. SMS 2003 site server or site systems that are
' Reporting Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers()

If AttributeValue_MicrosoftSMS2003ServerLocatorPointService() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers = True
Else
InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003SiteDatabaseServers
'
' Description: "Microsoft SMS 2003 Site Database Servers" computer
' group. SMS 2003 site server or site systems that are
' Site Database Servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003SiteDatabaseServers()

If AttributeValue_MicrosoftSMS2003SQLServer() And _
AttributeValue_MicrosoftSMS2003HighestVersionNumber() &gt; SMS2003_MIN_VERSION Then
InComputerGroup_MicrosoftSMS2003SiteDatabaseServers = True
Else
InComputerGroup_MicrosoftSMS2003SiteDatabaseServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003ComponentServersbasedonIIS
'
' Description: "Microsoft SMS 2003 Component Servers based on IIS"
' computer group. SMS 2003 site servers or site systems
' running IIS services.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003ComponentServersbasedonIIS()

InComputerGroup_MicrosoftSMS2003ComponentServersbasedonIIS = _
InComputerGroup_MicrosoftSMS2003ManagementPointServers() Or _
InComputerGroup_MicrosoftSMS2003ReportingPointServers() Or _
InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers()

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003Servers
'
' Description: "Microsoft SMS 2003 Servers" computer group.
' All qualifying (see group name) servers in the
' hierarchy (not just the site).
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003Servers()

InComputerGroup_MicrosoftSMS2003Servers = _
InComputerGroup_MicrosoftSMS2003ComponentServersbasedonSMSExecutive() Or _
InComputerGroup_MicrosoftSMS2003SiteDatabaseServers() Or _
InComputerGroup_MicrosoftSMS2003Providers() Or _
InComputerGroup_MicrosoftSMS2003DistributionPointServers() Or _
InComputerGroup_MicrosoftSMS2003ReportingPointServers() Or _
InComputerGroup_MicrosoftSMS2003ServerLocatorPointServers()

End Function

'=============
' Method: InComputerGroup_MicrosoftSMS2003SiteServers
'
' Description: "Microsoft SMS 2003 Site Servers" computer group.
' SMS 2003 site servers that are primary or secondary
' site servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMS2003SiteServers()

InComputerGroup_MicrosoftSMS2003SiteServers = _
InComputerGroup_MicrosoftSMS2003PrimarySiteServers() Or _
InComputerGroup_MicrosoftSMS2003SecondarySiteServers()

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003AgentHostService
'
' Description: "Microsoft SMS 2003 Agent Host Service" computer
' attribute. Checks for installation of SMS Agent Host
' service.
'
' Parameters: None
'
' Returns: True if registry key string value
' SYSTEM\CurrentControlSet\Services\CcmExec\DisplayName
' exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003AgentHostService()

AttributeValue_MicrosoftSMS2003AgentHostService = g_oUtil.CheckRegistryKeyStringValueExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SERVICES_CCMEXEC, g_oUtil.REG_VALUE_SERVICES_DISPLAY_NAME)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003DistributionPoint
'
' Description: "Microsoft SMS 2003 Distribution Point" computer
' attribute. Checks for installation of SMS Distribution
' Point.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\Operations
' Management\SMS Server Role\SMS Distribution Point exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003DistributionPoint()

AttributeValue_MicrosoftSMS2003DistributionPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_DISTRIBUTION_POINT)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ExecutiveService
'
' Description: "Microsoft SMS 2003 Executive Service" computer
' attribute. Checks for installation of SMS Executive
' service.
'
' Parameters: None
'
' Returns: True if registry key string value
' SYSTEM\CurrentControlSet\Services\SMS_EXECUTIVE\
' DisplayName exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003ExecutiveService()

AttributeValue_MicrosoftSMS2003ExecutiveService = g_oUtil.CheckRegistryKeyStringValueExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SERVICES_SMS_EXECUTIVE, g_oUtil.REG_VALUE_SERVICES_DISPLAY_NAME)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003InboxManagerAssistant
'
' Description: "Microsoft SMS 2003 Inbox Manager Assistant" computer
' attribute. Checks for installation of Inbox Manager
' Assistant.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\COMPONENTS\
' SMS_EXECUTIVE\Threads\SMS_INBOX_MANAGER_ASSISTANT exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003InboxManagerAssistant()

AttributeValue_MicrosoftSMS2003InboxManagerAssistant = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SMSEXEC_INBOX_MANAGER_ASSISTANT)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003LANSender
'
' Description: "Microsoft SMS 2003 LAN Sender" computer attribute.
' Checks for the installation of SMS LAN Sender.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\COMPONENTS\
' SMS_EXECUTIVE\Threads\SMS_LAN_SENDER exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003LANSender()

AttributeValue_MicrosoftSMS2003LANSender = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SMSEXEC_SMS_LAN_SENDER)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ManagementPointControlManager
'
' Description: "Microsoft SMS 2003 Management Point Control Manager"
' computer attribute. Checks for the installation of
' SMS Management Point Control Manager.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\COMPONENTS\
' SMS_EXECUTIVE\Threads\SMS_MP_CONTROL_MANAGER exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003ManagementPointControlManager()

AttributeValue_MicrosoftSMS2003ManagementPointControlManager = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_CONTROL_MANAGER)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ManagementPointFileDispatchManager
'
' Description: "Microsoft SMS 2003 Management Point File Dispatch Manager"
' computer attribute. Checks for installation of
' SMS Management Point File Dispatch Manager.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\COMPONENTS\
' SMS_EXECUTIVE\Threads\SMS_MP_FILE_DISPATCH_MANAGER exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003ManagementPointFileDispatchManager()

AttributeValue_MicrosoftSMS2003ManagementPointFileDispatchManager = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_FILE_DISPATCH_MANAGER)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003HighestVersionNumber
'
' Description: "Microsoft SMS 2003 Highest Version Number" computer
' attribute. A string containing the Operations Management
' version number for an SMS Server, the highest SMS Server
' component version.
'
' Parameters: None
'
' Returns: Registry key string value SOFTWARE\Microsoft\SMS\
' Operations Management\Version
'=============
Public Function AttributeValue_MicrosoftSMS2003HighestVersionNumber()

AttributeValue_MicrosoftSMS2003HighestVersionNumber = g_oUtil.ReadRegistryStringValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPERATIONS_MANAGEMENT, g_oUtil.REG_VALUE_SMS_SERVER_VERSION)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003CentralSiteServer
'
' Description: "Microsoft SMS 2003 Central Site Server" computer
' attribute. A DWORD value indicating if an SMS Site
' Server is a Central Site Server.
'
' Parameters: None
'
' Returns: Registry key DWORD value SOFTWARE\Microsoft\SMS\
' Operations Management\SMS Server Role\SMS Site Server\
' Central Site
'=============
Public Function AttributeValue_MicrosoftSMS2003CentralSiteServer()

AttributeValue_MicrosoftSMS2003CentralSiteServer = g_oUtil.ReadRegistryDWORDValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SITE_SERVER, g_oUtil.REG_VALUE_SMS_SERVER_CENTRAL_SITE)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ParentSiteCode
'
' Description: "Microsoft SMS 2003 Parent Site Code" computer
' attribute. A string containing the parent site code
' for an SMS Site Server. This value is empty on a
' Central Site Server.
'
' Parameters: None
'
' Returns: Registry key string value SOFTWARE\Microsoft\SMS\
' Identification\Parent Site Code
'=============
Public Function AttributeValue_MicrosoftSMS2003ParentSiteCode()

AttributeValue_MicrosoftSMS2003ParentSiteCode = g_oUtil.ReadRegistryStringValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_IDENTIFICATION, g_oUtil.REG_VALUE_SMS_SERVER_PARENT_SITE_CODE)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003Provider
'
' Description: "Microsoft SMS 2003 Provider" computer attribute.
' Checks for installation of SMS WMI Provider.
'
' Parameters: None
'
' Returns: True if registry key string value
' SOFTWARE\Microsoft\SMS\Providers\Binary Directory
' exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003Provider()

AttributeValue_MicrosoftSMS2003Provider = g_oUtil.CheckRegistryKeyStringValueExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_PROVIDERS, g_oUtil.REG_VALUE_SMS_SERVER_BINARY_DIRECTORY)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ReportingPointService
'
' Description: "Microsoft SMS 2003 Reporting Point Service" computer
' attribute. Checks for installation of SMS Reporting
' Point service.
'
' Parameters: None
'
' Returns: True if registry key string value
' SYSTEM\CurrentControlSet\Services\SMS_REPORTING_POINT\
' DisplayName exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003ReportingPointService()

AttributeValue_MicrosoftSMS2003ReportingPointService = g_oUtil.CheckRegistryKeyStringValueExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SERVICES_SMS_REPORTING_POINT, g_oUtil.REG_VALUE_SERVICES_DISPLAY_NAME)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003SiteCode
'
' Description: "Microsoft SMS 2003 Site Code" computer attribute.
' A string containing the site code for an SMS Site
' Server.
'
' Parameters: None
'
' Returns: Registry key string value SOFTWARE\Microsoft\SMS\
' Identification\Site Code
'=============
Public Function AttributeValue_MicrosoftSMS2003SiteCode()

AttributeValue_MicrosoftSMS2003SiteCode = g_oUtil.ReadRegistryStringValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_IDENTIFICATION, g_oUtil.REG_VALUE_SMS_SERVER_SITE_CODE)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003ServerLocatorPointService
'
' Description: "Microsoft SMS 2003 Server Locator Point Service"
' computer attribute. Checks for installation of
' SMS Server Locator Point service.
'
' Parameters: None
'
' Returns: True if registry key string value
' SYSTEM\CurrentControlSet\Services\SMS_SERVER_LOCATOR_POINT\
' DisplayName exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003ServerLocatorPointService()

AttributeValue_MicrosoftSMS2003ServerLocatorPointService = g_oUtil.CheckRegistryKeyStringValueExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SERVICES_SMS_SERVER_LOCATOR_POINT, g_oUtil.REG_VALUE_SERVICES_DISPLAY_NAME)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003SiteServerType
'
' Description: "Microsoft SMS 2003 Site Server Type" computer
' attribute. A DWORD value indicating the type of
' SMS Site Server.
'
' Parameters: None
'
' Returns: Registry key DWORD value SOFTWARE\Microsoft\SMS\
' Setup\Type
'=============
Public Function AttributeValue_MicrosoftSMS2003SiteServerType()

AttributeValue_MicrosoftSMS2003SiteServerType = g_oUtil.ReadRegistryDWORDValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SETUP, g_oUtil.REG_VALUE_SMS_SERVER_TYPE)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003SiteServerVersionNumber
'
' Description: "Microsoft SMS 2003 Site Server Version Number" computer
' attribute. A string containing the full version number
' for an SMS Server.
'
' Parameters: None
'
' Returns: Registry key string value SOFTWARE\Microsoft\SMS\Setup\
' Full Version
'=============
Public Function AttributeValue_MicrosoftSMS2003SiteServerVersionNumber()

AttributeValue_MicrosoftSMS2003SiteServerVersionNumber = g_oUtil.ReadRegistryStringValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_SETUP, g_oUtil.REG_VALUE_SMS_SERVER_FULL_VERSION)

End Function

'=============
' Method: AttributeValue_MicrosoftSMS2003SQLServer
'
' Description: "Microsoft SMS 2003 SQL Server" computer attribute.
' Checks for the installation of Microsoft SMS 2003 SQL
' Server.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\Operations
' Management\SMS Server Role\SMS SQL Server exists.
'=============
Public Function AttributeValue_MicrosoftSMS2003SQLServer()

AttributeValue_MicrosoftSMS2003SQLServer = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SQL_SERVER)

End Function

End Class

'==========================================================================
' Class: Util
' Description: Wrapper around WMI.
'==========================================================================
Class Util

'---------------
' Constants (Initialized on constructor due to VBS behavior)
'---------------

'Used to indicate to LogMessage when/how to print the message.
Public DBG_NONE
Public DBG_ERROR
Public DBG_WARNING
Public DBG_TRACE

'Internal Debug Level
Private m_nDebugLevel

'Registry hive constants
Public HKEY_CLASSES_ROOT
Public HKEY_CURRENT_USER
Public HKEY_LOCAL_MACHINE
Public HKEY_USERS
Public HKEY_CURRENT_CONFIG
Public HKEY_DYN_CONFIG

'Registry access permissions
Public KEY_QUERY_VALUE
Public KEY_SET_VALUE
Public KEY_CREATE_SUB_KEY
Public KEY_ENUMERATE_SUB_KEYS
Public KEY_NOTIFY
Public KEY_CREATE_LINK
Public DELETE
Public READ_CONTROL
Public WRITE_DAC
Public WRITE_OWNER

'Registry path and key name constants
Public REG_PATH_SERVICES
Public REG_PATH_SERVICES_BASE

Public REG_PATH_SMS
Public REG_PATH_SMS_BASE

Public REG_PATH_SMS_CLIENT

Public REG_PATH_SMS_SERVER

Public REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE
Public REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE

Public REG_PATH_SMS_SERVER_COMPONENTS
Public REG_PATH_SMS_SERVER_COMPONENTS_BASE

Public REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE

Public REG_PATH_SMS_SERVER_PROVIDERS
Public REG_PATH_SMS_SERVER_PROVIDERS_BASE

Public REG_KEY_SERVICES_CCMEXEC
Public REG_KEY_SERVICES_SMS_EXECUTIVE
Public REG_KEY_SERVICES_SMS_REPORTING_POINT
Public REG_KEY_SERVICES_SMS_SERVER_LOCATOR_POINT

Public REG_KEY_SMS_SERVER_IDENTIFICATION
Public REG_KEY_SMS_SERVER_OPERATIONS_MANAGEMENT
Public REG_KEY_SMS_SERVER_SETUP

Public REG_KEY_SMS_SERVER_OPMGMT_DISTRIBUTION_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_SITE_SERVER
Public REG_KEY_SMS_SERVER_OPMGMT_SQL_SERVER

Public REG_KEY_SMS_SERVER_SMSEXEC_INBOX_MANAGER_ASSISTANT
Public REG_KEY_SMS_SERVER_SMSEXEC_SMS_LAN_SENDER
Public REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_CONTROL_MANAGER
Public REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_FILE_DISPATCH_MANAGER

Public REG_KEY_SMS_SERVER_PROVIDERS

'Registry key value name constants
Public REG_VALUE_SERVICES_DISPLAY_NAME

Public REG_VALUE_SMS_CLIENT_VERSION
Public REG_VALUE_SMS_CLIENT_SITE_CODE

Public REG_VALUE_SMS_SERVER_VERSION
Public REG_VALUE_SMS_SERVER_FULL_VERSION
Public REG_VALUE_SMS_SERVER_SITE_CODE
Public REG_VALUE_SMS_SERVER_PARENT_SITE_CODE
Public REG_VALUE_SMS_SERVER_CENTRAL_SITE
Public REG_VALUE_SMS_SERVER_BINARY_DIRECTORY
Public REG_VALUE_SMS_SERVER_TYPE

'---------------
' Methods
'---------------

'=============
' Method: Class_Initialize
' Description: This is the constructor
' Parameters:
'=============
Private Sub Class_Initialize()

'Initialize Debug level constants
DBG_TRACE = 1
DBG_WARNING = 2
DBG_ERROR = 3
DBG_NONE = 4

'by default only errors are logged
m_nDebugLevel = DBG_ERROR

'Registry hive constants
HKEY_CLASSES_ROOT = &amp;H80000000
HKEY_CURRENT_USER = &amp;H80000001
HKEY_LOCAL_MACHINE = &amp;H80000002
HKEY_USERS = &amp;H80000003
HKEY_CURRENT_CONFIG = &amp;H80000005
HKEY_DYN_CONFIG = &amp;H80000006

'Registry access permissions
KEY_QUERY_VALUE = &amp;H1
KEY_SET_VALUE = &amp;H2
KEY_CREATE_SUB_KEY = &amp;H4
KEY_ENUMERATE_SUB_KEYS = &amp;H8
KEY_NOTIFY = &amp;H10
KEY_CREATE_LINK = &amp;H20
DELETE = &amp;H10000
READ_CONTROL = &amp;H20000
WRITE_DAC = &amp;H40000
WRITE_OWNER = &amp;H80000

'Registry path and key name constants
REG_PATH_SERVICES = "SYSTEM\CurrentControlSet\Services"
REG_PATH_SERVICES_BASE = REG_PATH_SERVICES + "\"

REG_PATH_SMS = "SOFTWARE\Microsoft\SMS"
REG_PATH_SMS_BASE = REG_PATH_SMS + "\"

REG_PATH_SMS_CLIENT = REG_PATH_SMS_BASE + "Mobile Client"

REG_PATH_SMS_SERVER = REG_PATH_SMS

REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE = REG_PATH_SMS_BASE + "Operations Management\SMS Server Role"
REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE + "\"

REG_PATH_SMS_SERVER_COMPONENTS = REG_PATH_SMS_BASE + "COMPONENTS"
REG_PATH_SMS_SERVER_COMPONENTS_BASE = REG_PATH_SMS_SERVER_COMPONENTS + "\"

REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE = REG_PATH_SMS_SERVER_COMPONENTS_BASE + "SMS_EXECUTIVE\Threads\"

REG_PATH_SMS_SERVER_PROVIDERS = REG_PATH_SMS_BASE + "Providers"
REG_PATH_SMS_SERVER_PROVIDERS_BASE = REG_PATH_SMS_SERVER_PROVIDERS + "\"

REG_KEY_SERVICES_CCMEXEC = REG_PATH_SERVICES_BASE + "CcmExec"
REG_KEY_SERVICES_SMS_EXECUTIVE = REG_PATH_SERVICES_BASE + "SMS_EXECUTIVE"
REG_KEY_SERVICES_SMS_REPORTING_POINT = REG_PATH_SERVICES_BASE + "SMS_REPORTING_POINT"
REG_KEY_SERVICES_SMS_SERVER_LOCATOR_POINT = REG_PATH_SERVICES_BASE + "SMS_SERVER_LOCATOR_POINT"

REG_KEY_SMS_SERVER_IDENTIFICATION = REG_PATH_SMS_BASE + "Identification"
REG_KEY_SMS_SERVER_OPERATIONS_MANAGEMENT = REG_PATH_SMS_BASE + "Operations Management"
REG_KEY_SMS_SERVER_SETUP = REG_PATH_SMS_BASE + "Setup"

REG_KEY_SMS_SERVER_OPMGMT_DISTRIBUTION_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Distribution Point"
REG_KEY_SMS_SERVER_OPMGMT_SITE_SERVER = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Site Server"
REG_KEY_SMS_SERVER_OPMGMT_SQL_SERVER = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS SQL Server"

REG_KEY_SMS_SERVER_SMSEXEC_INBOX_MANAGER_ASSISTANT = REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE + "SMS_INBOX_MANAGER_ASSISTANT"
REG_KEY_SMS_SERVER_SMSEXEC_SMS_LAN_SENDER = REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE + "SMS_LAN_SENDER"
REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_CONTROL_MANAGER = REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE + "SMS_MP_CONTROL_MANAGER"
REG_KEY_SMS_SERVER_SMSEXEC_SMS_MP_FILE_DISPATCH_MANAGER = REG_PATH_SMS_SERVER_SMSEXEC_COMP_BASE + "SMS_MP_FILE_DISPATCH_MANAGER"

REG_KEY_SMS_SERVER_PROVIDERS = REG_PATH_SMS_SERVER_PROVIDERS

'Registry key value name constants
REG_VALUE_SERVICES_DISPLAY_NAME = "DisplayName"

REG_VALUE_SMS_CLIENT_VERSION = "ProductVersion"
REG_VALUE_SMS_CLIENT_SITE_CODE = "AssignedSiteCode"

REG_VALUE_SMS_SERVER_VERSION = "Version"
REG_VALUE_SMS_SERVER_FULL_VERSION = "Full Version"
REG_VALUE_SMS_SERVER_SITE_CODE = "Site Code"
REG_VALUE_SMS_SERVER_PARENT_SITE_CODE = "Parent Site Code"
REG_VALUE_SMS_SERVER_CENTRAL_SITE = "Central Site"
REG_VALUE_SMS_SERVER_BINARY_DIRECTORY = "Binary Directory"
REG_VALUE_SMS_SERVER_TYPE = "Type"

End Sub

'=============
' Method: Class_Terminate
' Description: This is the destructor
' Parameters:
'=============
Private Sub Class_Terminate()
End Sub

'=============
' Method: SetDebugLevel
' Description: To change the debugging output level of information
' generated by this utility.
' Parameters:
' nLevel - Level, either DBG_NONE, DBG_TRACE,
' DBG_WARNING or DBG_ERROR
'=============
Public Sub SetDebugLevel(ByVal nLevel)
m_nDebugLevel = nLevel
End Sub

'=============
' Method: LogMessage
' Description: Log a debug message to ScriptContext
' Parameters:
' nLevel - Debug level for the message that we're logging.
' strMessage - The message to write to the trace.
'=============
Public Sub LogMessage(ByVal nLevel, ByVal strMessage)

If (nLevel &lt;= m_nDebugLevel) Then
If (nLevel = DBG_ERROR) Then
ScriptContext.Echo "[Error]: " + strMessage
ElseIf (nLevel = DBG_WARNING) Then
ScriptContext.Echo "[Warning]: " + strMessage
ElseIf (nLevel = DBG_TRACE) Then
ScriptContext.Echo "[Trace]:" + strMessage
End If
End If

End Sub

'=============
' Method: ReadRegistryStringValue
' Description: Used to read strings from the registry
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to read
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' strValueName - Name of the registry value to read (like "SoftwareType")
'
' Returns:
' The value of the registry key specified. "Nothing" if it fails.
' Callee needs to handle null value return.
'=============
Public Function ReadRegistryStringValue(ByVal lHive, ByVal strKeyPath, ByVal strValueName)

Dim oReg
Dim strValueData

'Get registry provider object
Call LogMessage(DBG_TRACE, "Connecting to WMI Registry : " + "winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")
Set oReg = WMIGetObject("winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")

'Read from value from registry
if oReg.GetStringValue(lHive, strKeyPath, strValueName, strValueData) = 0 Then
Call LogMessage(DBG_TRACE, "Value of Registry Key: " + strKeyPath + "\" + strValueName + " = " + strValueData)
ReadRegistryStringValue = strValueData
Else
Call LogMessage(DBG_ERROR, "Reading Registry Key: " + strKeyPath + "\" + strValueName + " Failed!" )
ReadRegistryStringValue = Empty
End If

Set oReg = Nothing

End Function

'=============
' Method: ReadRegistryDWORDValue
' Description: Used to read DWORDs from the registry
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to read
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' strValueName - Name of the registry value to read (like "SoftwareType")
'
' Returns:
' The value of the registry key specified. "Nothing" if it fails.
' Callee needs to handle null value return.
'=============
Public Function ReadRegistryDWORDValue(ByVal lHive, ByVal strKeyPath, ByVal strValueName)

Dim oReg
Dim lValueData

'Get registry provider object
Call LogMessage(DBG_TRACE, "Connecting to WMI Registry : " + "winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")
Set oReg = WMIGetObject("winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")

'Read value from registry
if oReg.GetDWORDValue(lHive, strKeyPath, strValueName, lValueData) = 0 Then
Call LogMessage(DBG_TRACE, "Value of Registry Key: " + strKeyPath + "\" + strValueName + " = " &amp; lValueData)
ReadRegistryDWORDValue = lValueData
Else
Call LogMessage(DBG_ERROR, "Reading Registry Key: " + strKeyPath + "\" + strValueName + " Failed!" )
ReadRegistryDWORDValue = Empty
End If

Set oReg = Nothing

End Function

'=============
' Method: EnumRegistryKeys
' Description: Used to enumerate registry keys under a given path
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to read
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' Returns:
' The list of registry keys found under the path. "null" if the list is empty
'=============
Public Function EnumRegistryKeys(ByVal lHive, ByVal strKeyPath)

Dim oReg
Dim arrKeys

'Get registry provider object
Call LogMessage(DBG_TRACE, "Connecting to WMI Registry : " + "winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")
Set oReg = WMIGetObject("winmgmts:\\"+ ScriptContext.TargetComputer + "\root\default:StdRegProv")

'Enumerate keys in registry
if oReg.EnumKey(lHive, strKeyPath, arrKeys) = 0 Then
Call LogMessage(DBG_TRACE, "Found [" + arrKeys(0) + "] key in path : " + strKeyPath )
EnumRegistryKeys = arrKeys
Else
Call LogMessage(DBG_ERROR, "Error enumerating Registry Keys under path : " + strKeyPath )
End If

Set oReg = Nothing

End Function

'=============
' Method: CheckRegistryKeyAccess
' Description: Used to check permissions access to a registry key
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to check access
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' lAccess - required permissions i.e. KEY_QUERY_VALUE + KEY_SET_VALUE
' Returns:
' True if the specified permissions are present on the registry key else false.
'=============
Public Function CheckRegistryKeyAccess(ByVal lHive, ByVal strKeyPath, ByVal lAccess)

Dim oReg
Dim bGranted

'Get registry provider object
Call LogMessage(DBG_TRACE, "Connecting to WMI Registry : " + "winmgmts:\\"+ ScriptContext.TargetComputer+ "\root\default:StdRegProv")
Set oReg = WMIGetObject("winmgmts:\\"+ ScriptContext.TargetComputer + "\root\default:StdRegProv")

'Check access to the specified registry key
if oReg.CheckAccess(lHive, strKeyPath, lAccess, bGranted) = 0 Then
Call LogMessage(DBG_TRACE, "Required access present on registry key : " + strKeyPath )
CheckRegistryKeyAccess = bGranted
Else
Call LogMessage(DBG_ERROR, "Error checking access on registry keys : " + strKeyPath )
CheckRegistryKeyAccess = False
End If

Set oReg = Nothing

End Function

'=============
' Method: CheckRegistryKeyExists
' Description: Used to check existence of a registry key
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to check access
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' Returns:
' True if the registry key exists else false.
'=============
Public Function CheckRegistryKeyExists(ByVal lHive, ByVal strKeyPath)

CheckRegistryKeyExists = CheckRegistryKeyAccess(lHive, strKeyPath, KEY_QUERY_VALUE)

End Function

'=============
' Method: CheckRegistryKeyStringValueExists
' Description: Used to check existence of a registry key string value
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to check access
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' Returns:
' True if the string value exists else false.
'=============
Public Function CheckRegistryKeyStringValueExists(ByVal lHive, ByVal strKeyPath, ByVal strValueName)

Dim strValue

strValue = ReadRegistryStringValue(lHive, strKeyPath, strValueName)

If IsEmpty(strValue) Then
CheckRegistryKeyStringValueExists = False
Else
CheckRegistryKeyStringValueExists = True
End If

End Function

'=============
' Method: CheckRegistryKeyDWORDValueExists
' Description: Used to check existence of a registry key DWORD value
' Parameters:
' lHive - Registry hive or root i.e. HKEY_LOCAL_MACHINE
' strKeyPath - Key path for the Registry key to check access
' (like "SOFTWARE\Microsoft\WindowsNT\CurrentVersion")
' Returns:
' True if the DWORD value exists else false.
'=============
Public Function CheckRegistryKeyDWORDValueExists(ByVal lHive, ByVal strKeyPath, ByVal strValueName)

Dim lValue

lValue = ReadRegistryDWORDValue(lHive, strKeyPath, strValueName)

If IsEmpty(lValue) Then
CheckRegistryKeyDWORDValueExists = False
Else
CheckRegistryKeyDWORDValueExists = True
End If

End Function

End Class

'=============
' Method: WMIGetObject
' Description: Returns an object of type SWbemObjectSet
' Parameters:
' sNamespace - A WMI Namespace (ex. winmgmts:\\COMPUTERNAME\ROOT\cimv2).
'=============
Function WMIGetObject(sNamespace)
Dim oWMI
Dim nErrNumber, sErrDescription

On Error Resume Next
Set oWMI = GetObject(sNamespace)
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If IsEmpty(oWMI) Or nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "Unable to open WMI Namespace " &amp; sNamespace
Err.Raise 9100, GET_WMI_NO_NAMESPACE_SOURCE(sNamespace), GET_WMI_NO_NAMESPACE_DESCRIPTION(nErrNumber, sErrDescription)
End If

Set WMIGetObject = oWMI

Set oWMI = Nothing
End Function

'=============
' Method: WMIGetInstance
' Description: Returns an object of type SWbemObjectSet
' Parameters:
' sNamespace - A WMI Namespace (ex. winmgmts:\\COMPUTERNAME\ROOT\cimv2).
' sInstance - A WMI Namespace Instance (ex. Win32_OperatingSystem)
'=============
Function WMIGetInstance(sNamespace, sInstance)
Dim oWMI, oInstance
Dim nErrNumber, sErrDescription

On Error Resume Next
Set oWMI = GetObject(sNamespace)
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If IsEmpty(oWMI) Or nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "Unable to open WMI Namespace " &amp; sNamespace
Err.Raise 9100, GET_WMI_NO_NAMESPACE_SOURCE(sNamespace), GET_WMI_NO_NAMESPACE_DESCRIPTION(nErrNumber, sErrDescription)
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If IsEmpty(oInstance) Or nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "The class name '" &amp; sInstance &amp; "' returned no instances. Error:" &amp; nErrNumber &amp; ", " &amp; sErrDescription &amp; "."
Err.Raise 9100, GET_WMI_NO_INSTANCES_SOURCE(sInstance), GET_WMI_NO_INSTANCES_DESCRIPTION(nErrNumber, sErrDescription)
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty
On Error Resume Next
Dim nInstanceCount
nInstanceCount = oInstance.Count
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "The class name '" &amp; sInstance &amp; "' did not return any valid instances. Error:" &amp; nErrNumber &amp; ", " &amp; sErrDescription &amp; "."
Err.Raise 9100, GET_WMI_NO_VALID_INSTANCES_SOURCE(sInstance), GET_WMI_NO_VALID_INSTANCES_DESCRIPTION(nErrNumber, sErrDescription)
End If

Set WMIGetInstance = oInstance

Set oInstance = Nothing
Set oWMI = Nothing
End Function

'=============
' Method: WMIExecQuery
' Description: Returns an object of type SWbemObjectSet
' Parameters:
' sNamespace - A WMI Namespace (ex. winmgmts:\\COMPUTERNAME\ROOT\cimv2).
' sQuery - A SQL Query (ex. SELECT * FROM Win32_OperatingSystem)
'=============
Function WMIExecQuery(sNamespace, sQuery)
Dim oWMI, oQuery
Dim nErrNumber, sErrDescription

On Error Resume Next
Set oWMI = GetObject(sNamespace)
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0

If IsEmpty(oWMI) Or nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "Unable to open WMI Namespace " &amp; sNamespace
Err.Raise 9100, GET_WMI_NO_NAMESPACE_SOURCE(sNamespace), GET_WMI_NO_NAMESPACE_DESCRIPTION(nErrNumber, sErrDescription)
End If

On Error Resume Next
Set oQuery = oWMI.ExecQuery(sQuery)
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If IsEmpty(oQuery) Or nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "The Query '" &amp; sQuery &amp; "' returned an invalid result set. Error:" &amp; nErrNumber &amp; ", " &amp; sErrDescription &amp; "."
Err.Raise 9100, GET_WMI_QUERY_NO_RESULTS_SOURCE(sQuery), GET_WMI_QUERY_NO_RESULTS_DESCRIPTION(nErrNumber, sErrDescription)
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty
On Error Resume Next
Dim nInstanceCount
nInstanceCount = oQuery.Count
nErrNumber = Err.Number
sErrDescription = Err.Description
On Error Goto 0
If nErrNumber &lt;&gt; 0 Then
ScriptContext.Echo "The Query '" &amp; sQuery &amp; "' did not return any valid instances. Error:" &amp; nErrNumber &amp; ", " &amp; sErrDescription &amp; "."
Err.Raise 9100, GET_WMI_QUERY_NO_VALID_INSTANCES_SOURCE(sQuery), GET_WMI_QUERY_NO_VALID_INSTANCES_DESCRIPTION(nErrNumber, sErrDescription)
End If

Set WMIExecQuery = oQuery

Set oQuery = Nothing
Set oWMI = Nothing

End Function</Script></Body>
<Language>VBScript</Language>
<Name>SMS 2003 Service Discovery - Server</Name>
<Parameters/>
<ManagementPackId>[Microsoft.SMS.2003,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>