ConfigMgr 2007 服務探索 - 伺服器

SMSv4_Service_Discovery___Server (WriteActionModuleType)

執行 ConfigMgr 伺服器的服務探索

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{C5A1AB22-2DE2-47C4-896E-12BCFC3D069F}

Member Modules:

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

Source Code:

<WriteActionModuleType ID="SMSv4_Service_Discovery___Server" Accessibility="Internal" Comment="{C5A1AB22-2DE2-47C4-896E-12BCFC3D069F}">
<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 - ConfigMgr 2007 Service Discovery - Server
'
' Purpose - Performs service discovery functions on ConfigMgr 2007 Servers.
'
' Assumptions - This script will only run on ConfigMgr 2007 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_MicrosoftSMSv4SQLServer
' 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.
' 04/23/05 05.0.2754.0000 Updated for SMSv4.
' 01/06/06 05.0.2809.0000 Change computer attribute and group
' functions to use Operations Management
' registry information.
' 04/08/06 05.0.2902.0000 Updated for SMP and PSP.
' 08/03/06 05.0.2905.0000 Updated for SUP.
' 07/29/07 05.0.2906.0000 Removed Sender discovery and added FSP.
' 08/18/07 6.0.5000.2 Added event tracing support.
' 09/21/07 6.0.5000.6 Changed function
' CheckWow64RegistryKeyExists() to
' not just check for the Wow6432Node
' key but also the SMS key under it.
'
' (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 = "{BCD40058-E0D9-4E54-BD4D-510D30CD2918}" '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_SITE_DATABASE_COMPONENT_ID = "DB"
Const SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID = "DP"
Const SMS_SERVER_FALLBACK_STATUS_POINT_COMPONENT_ID = "FSP"
Const SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID = "MP"
Const SMS_SERVER_PROVIDER_COMPONENT_ID = "Provider"
Const SMS_SERVER_PXE_SERVICE_POINT_COMPONENT_ID = "PSP"
Const SMS_SERVER_REPORTING_POINT_COMPONENT_ID = "RP"
'Const SMS_SERVER_SENDER_COMPONENT_ID = "Sender"
Const SMS_SERVER_SYSTEM_HEALTH_VALIDATOR_COMPONENT_ID = "SHV"
Const SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID = "SLP"
Const SMS_SERVER_STATE_MIGRATION_POINT_COMPONENT_ID = "SMP"
Const SMS_SERVER_SITE_SERVER_COMPONENT_ID = "SS"
Const SMS_SERVER_SOFTWARE_UPDATE_POINT_COMPONENT_ID = "SUP"
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 = "ConfigMgr 2007 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()

Dim bEventTracing


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))

'Check if event tracing is configured. If it is, raise a start event.
'=====================================================================

bEventTracing = IsEventTracingEnabled()

If (bEventTracing = True) Then
LogEvent EVENT_ID_NOTANEVENT, EVENT_TYPE_INFORMATION, "started at local time: " &amp; CStr(Time)
End If

'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

If (bEventTracing = True) Then
LogEvent EVENT_ID_SCRIPTSUCCESS, EVENT_TYPE_INFORMATION, "completed at local time: " &amp; CStr(Time)
End If

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_SITE_DATABASE_COMPONENT_ID
.AddScopeComponent SMS_SERVER_DISTRIBUTION_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_FALLBACK_STATUS_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_MANAGEMENT_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_PROVIDER_COMPONENT_ID
.AddScopeComponent SMS_SERVER_PXE_SERVICE_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_REPORTING_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SYSTEM_HEALTH_VALIDATOR_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SERVER_LOCATOR_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_STATE_MIGRATION_POINT_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SITE_SERVER_COMPONENT_ID
.AddScopeComponent SMS_SERVER_SOFTWARE_UPDATE_POINT_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_MicrosoftSMSv4SiteDatabaseServers() 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_MicrosoftSMSv4DistributionPointServers() 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_MicrosoftSMSv4FallbackStatusPointServers() Then

oInstance.AddComponent SMS_SERVER_FALLBACK_STATUS_POINT_COMPONENT_ID

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

End If

If oSMSServer.InComputerGroup_MicrosoftSMSv4ManagementPointServers() 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_MicrosoftSMSv4Providers() 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_MicrosoftSMSv4PXEServicePointServers() Then

oInstance.AddComponent SMS_SERVER_PXE_SERVICE_POINT_COMPONENT_ID

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

End If

If oSMSServer.InComputerGroup_MicrosoftSMSv4ReportingPointServers() 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_MicrosoftSMSv4SystemHealthValidatorServers() Then

oInstance.AddComponent SMS_SERVER_SYSTEM_HEALTH_VALIDATOR_COMPONENT_ID

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

End If

If oSMSServer.InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers() 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_MicrosoftSMSv4StateMigrationPointServers() Then

oInstance.AddComponent SMS_SERVER_STATE_MIGRATION_POINT_COMPONENT_ID

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

End If

If oSMSServer.InComputerGroup_MicrosoftSMSv4SiteServers() 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

If oSMSServer.InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers() Then

oInstance.AddComponent SMS_SERVER_SOFTWARE_UPDATE_POINT_COMPONENT_ID

If IsEmpty(strSMSComponents) Then
strSMSComponents = SMS_SERVER_SOFTWARE_UPDATE_POINT_COMPONENT_ID
Else
strSMSComponents = strSMSComponents &amp; ", " &amp; SMS_SERVER_SOFTWARE_UPDATE_POINT_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_MicrosoftSMSv4CentralSiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_CENTRAL_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMSv4PrimarySiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_PRIMARY_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMSv4SecondarySiteServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_SECONDARY_SITE
ElseIf oSMSServer.InComputerGroup_MicrosoftSMSv4DistributionPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4FallbackStatusPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4PXEServicePointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4ReportingPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4SystemHealthValidatorServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4StateMigrationPointServers() Or _
oSMSServer.InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers() Then
oInstance.AddProperty SMS_SERVER_SHAPE_ANNOTATION_1_ATTRIBUTE_ID, SMS_SERVER_SHAPE_ANNOTATION_1_SITE_SYSTEM
End If

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

If oSMSServer.InComputerGroup_MicrosoftSMSv4SiteDatabaseServers() 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 SMSv4_MIN_VERSION

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

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

SMSv4_MIN_VERSION = "4.00.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()

GetSMSVersion = AttributeValue_MicrosoftSMSv4HighestVersionNumber()

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()

GetSMSSiteCode = AttributeValue_MicrosoftSMSv4SiteCode()

End Function

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

If AttributeValue_MicrosoftSMSv4CentralSiteServer() = 1 And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4CentralSiteServers = True
Else
InComputerGroup_MicrosoftSMSv4CentralSiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4ComponentServersbasedonSMSExecutive
'
' Description: "Microsoft ConfigMgr 2007 Component Servers based on
' SMS Executive" computer group. ConfigMgr 2007 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_MicrosoftSMSv4ComponentServersbasedonSMSExecutive()

If AttributeValue_MicrosoftSMSv4ExecutiveService() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4ComponentServersbasedonSMSExecutive = True
Else
InComputerGroup_MicrosoftSMSv4ComponentServersbasedonSMSExecutive = False
End If

End Function

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

If InComputerGroup_MicrosoftSMSv4ManagementPointServers() And _
AttributeValue_MicrosoftSMSv4ManagementPointDeviceManager() Then
InComputerGroup_MicrosoftSMSv4DeviceManagementPointServers = True
Else
InComputerGroup_MicrosoftSMSv4DeviceManagementPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4DistributionPointServers
'
' Description: "Microsoft ConfigMgr 2007 Distribution Point Servers"
' computer group. ConfigMgr 2007 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_MicrosoftSMSv4DistributionPointServers()

If AttributeValue_MicrosoftSMSv4DistributionPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4DistributionPointServers = True
Else
InComputerGroup_MicrosoftSMSv4DistributionPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4FallbackStatusPointServers
'
' Description: "Microsoft ConfigMgr 2007 Fallback Status Point Servers" computer group.
' ConfigMgr 2007 site servers or site systems that are Fallback Status
' Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMSv4FallbackStatusPointServers()

If AttributeValue_MicrosoftSMSv4FallbackStatusPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4FallbackStatusPointServers = True
Else
InComputerGroup_MicrosoftSMSv4FallbackStatusPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4ManagementPointServers
'
' Description: "Microsoft ConfigMgr 2007 Management Point Servers" computer
' group. ConfigMgr 2007 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_MicrosoftSMSv4ManagementPointServers()

If AttributeValue_MicrosoftSMSv4ManagementPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4ManagementPointServers = True
Else
InComputerGroup_MicrosoftSMSv4ManagementPointServers = False
End If

End Function

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

If AttributeValue_MicrosoftSMSv4SiteServerSiteType() = 1 And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4PrimarySiteServers = True
Else
InComputerGroup_MicrosoftSMSv4PrimarySiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4Providers
'
' Description: "Microsoft ConfigMgr 2007 Providers" computer group.
' ConfigMgr 2007 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_MicrosoftSMSv4Providers()

If AttributeValue_MicrosoftSMSv4Provider() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4Providers = True
Else
InComputerGroup_MicrosoftSMSv4Providers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4PXEServicePointServers
'
' Description: "Microsoft ConfigMgr 2007 PXE Service Point Servers" computer
' group. ConfigMgr 2007 site servers or site systems that are
' PXE Service Points.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMSv4PXEServicePointServers()

If AttributeValue_MicrosoftSMSv4PXEServicePoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4PXEServicePointServers = True
Else
InComputerGroup_MicrosoftSMSv4PXEServicePointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4ReportingPointServers
'
' Description: "Microsoft ConfigMgr 2007 Reporting Point Servers" computer
' group. ConfigMgr 2007 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_MicrosoftSMSv4ReportingPointServers()

If AttributeValue_MicrosoftSMSv4ReportingPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4ReportingPointServers = True
Else
InComputerGroup_MicrosoftSMSv4ReportingPointServers = False
End If

End Function

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

If AttributeValue_MicrosoftSMSv4SiteServerSiteType() = 2 And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4SecondarySiteServers = True
Else
InComputerGroup_MicrosoftSMSv4SecondarySiteServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers
'
' Description: "Microsoft ConfigMgr 2007 Server Locator Point Servers" computer
' group. ConfigMgr 2007 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_MicrosoftSMSv4ServerLocatorPointServers()

If AttributeValue_MicrosoftSMSv4ServerLocatorPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers = True
Else
InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4SiteDatabaseServers
'
' Description: "Microsoft ConfigMgr 2007 Site Database Servers" computer
' group. ConfigMgr 2007 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_MicrosoftSMSv4SiteDatabaseServers()

If AttributeValue_MicrosoftSMSv4SQLServer() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4SiteDatabaseServers = True
Else
InComputerGroup_MicrosoftSMSv4SiteDatabaseServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4StateMigrationPointServers
'
' Description: "Microsoft ConfigMgr 2007 State Migration Point Servers" computer
' group. ConfigMgr 2007 site server or site systems that are
' State Migration Point Servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMSv4StateMigrationPointServers()

If AttributeValue_MicrosoftSMSv4StateMigrationPoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4StateMigrationPointServers = True
Else
InComputerGroup_MicrosoftSMSv4StateMigrationPointServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4SystemHealthValidatorServers
'
' Description: "Microsoft ConfigMgr 2007 System Health Validator Servers" computer
' group. ConfigMgr 2007 site server or site systems that are
' running IAS and hosting the SMS System Health Validator.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMSv4SystemHealthValidatorServers()

If AttributeValue_MicrosoftSMSv4SystemHealthValidator() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4SystemHealthValidatorServers = True
Else
InComputerGroup_MicrosoftSMSv4SystemHealthValidatorServers = False
End If

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4ComponentServersbasedonIIS
'
' Description: "Microsoft ConfigMgr 2007 Component Servers based on IIS"
' computer group. ConfigMgr 2007 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_MicrosoftSMSv4ComponentServersbasedonIIS()

InComputerGroup_MicrosoftSMSv4ComponentServersbasedonIIS = _
InComputerGroup_MicrosoftSMSv4ManagementPointServers() Or _
InComputerGroup_MicrosoftSMSv4ReportingPointServers() Or _
InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers()

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4Servers
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4Servers()

InComputerGroup_MicrosoftSMSv4Servers = _
InComputerGroup_MicrosoftSMSv4ComponentServersbasedonSMSExecutive() Or _
InComputerGroup_MicrosoftSMSv4SiteDatabaseServers() Or _
InComputerGroup_MicrosoftSMSv4Providers() Or _
InComputerGroup_MicrosoftSMSv4DistributionPointServers() Or _
InComputerGroup_MicrosoftSMSv4ReportingPointServers() Or _
InComputerGroup_MicrosoftSMSv4ServerLocatorPointServers()

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4SiteServers
'
' Description: "Microsoft ConfigMgr 2007 Site Servers" computer group.
' ConfigMgr 2007 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_MicrosoftSMSv4SiteServers()

InComputerGroup_MicrosoftSMSv4SiteServers = _
InComputerGroup_MicrosoftSMSv4PrimarySiteServers() Or _
InComputerGroup_MicrosoftSMSv4SecondarySiteServers()

End Function

'=============
' Method: InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers
'
' Description: "Microsoft ConfigMgr 2007 Software Update Point Servers" computer
' group. ConfigMgr 2007 site server or site systems that are
' Software Update Point Servers.
'
' Parameters: None
'
' Returns: True if this server is in the computer group else false.
'=============
Public Function InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers()

If AttributeValue_MicrosoftSMSv4SoftwareUpdatePoint() And _
AttributeValue_MicrosoftSMSv4HighestVersionNumber() &gt; SMSv4_MIN_VERSION Then
InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers = True
Else
InComputerGroup_MicrosoftSMSv4SoftwareUpdatePointServers = False
End If

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4AgentHostService
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4AgentHostService()

AttributeValue_MicrosoftSMSv4AgentHostService = 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_MicrosoftSMSv4DistributionPoint
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4DistributionPoint()

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

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4ExecutiveService
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4ExecutiveService()

AttributeValue_MicrosoftSMSv4ExecutiveService = 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_MicrosoftSMSv4FallbackStatusPoint
'
' Description: "Microsoft ConfigMgr 2007 Fallback Status Point" computer attribute.
' Checks for the installation of SMS Fallback Status Point.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\
' Operations Management\SMS Server Role\
' SMS Fallback Status Point exists.
'=============
Public Function AttributeValue_MicrosoftSMSv4FallbackStatusPoint()

AttributeValue_MicrosoftSMSv4FallbackStatusPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_FALLBACK_STATUS_POINT)

End Function

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

AttributeValue_MicrosoftSMSv4ManagementPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_MANAGEMENT_POINT)

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4ManagementPointDeviceManager
'
' Description: "Microsoft ConfigMgr 2007 Management Point Device Manager"
' computer attribute. Checks for the installation of
' MP Device Manager.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\
' Operations Management\Components\SMS_MP_DEVICE_MANAGER
' exists.
'=============
Public Function AttributeValue_MicrosoftSMSv4ManagementPointDeviceManager()

AttributeValue_MicrosoftSMSv4ManagementPointDeviceManager = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_COMP_SMS_MP_DEVICE_MANAGER)

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4HighestVersionNumber
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4HighestVersionNumber()

AttributeValue_MicrosoftSMSv4HighestVersionNumber = 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_MicrosoftSMSv4CentralSiteServer
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4CentralSiteServer()

AttributeValue_MicrosoftSMSv4CentralSiteServer = 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_MicrosoftSMSv4ParentSiteCode
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4ParentSiteCode()

AttributeValue_MicrosoftSMSv4ParentSiteCode = 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_MicrosoftSMSv4Provider
'
' Description: "Microsoft ConfigMgr 2007 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_MicrosoftSMSv4Provider()

AttributeValue_MicrosoftSMSv4Provider = 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_MicrosoftSMSv4PXEServicePoint
'
' Description: "Microsoft ConfigMgr 2007 PXE Service Point" computer
' attribute. Checks for installation of SMS PXE Service
' Point.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\
' Operations Management\SMS Server Role\
' SMS PXE Service Point exists.
'=============
Public Function AttributeValue_MicrosoftSMSv4PXEServicePoint()

AttributeValue_MicrosoftSMSv4PXEServicePoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_PXE_SERVICE_POINT)

End Function

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

AttributeValue_MicrosoftSMSv4ReportingPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_REPORTING_POINT)

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4SiteCode
'
' Description: "Microsoft ConfigMgr 2007 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\
' Operations Management\Site Code
'=============
Public Function AttributeValue_MicrosoftSMSv4SiteCode()

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

End Function

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

AttributeValue_MicrosoftSMSv4ServerLocatorPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SERVER_LOCATOR_POINT)

End Function

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

AttributeValue_MicrosoftSMSv4SiteServerType = 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_MicrosoftSMSv4SiteServerSiteType
'
' Description: "Microsoft ConfigMgr 2007 Site Server Site Type" computer
' attribute. A DWORD value indicating the type of
' SMS Site Server.
'
' Parameters: None
'
' Returns: Registry key DWORD value SOFTWARE\Microsoft\SMS\
' Operations Management\SMS Server Role\SMS Site Server\
' Site Type
'=============
Public Function AttributeValue_MicrosoftSMSv4SiteServerSiteType()

AttributeValue_MicrosoftSMSv4SiteServerSiteType = g_oUtil.ReadRegistryDWORDValue(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SITE_SERVER, g_oUtil.REG_VALUE_SMS_SERVER_SITE_TYPE)

End Function

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

AttributeValue_MicrosoftSMSv4SoftwareUpdatePoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SOFTWARE_UPDATE_POINT)

End Function

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

AttributeValue_MicrosoftSMSv4StateMigrationPoint = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_STATE_MIGRATION_POINT)

End Function

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

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

End Function

'=============
' Method: AttributeValue_MicrosoftSMSv4SystemHealthValidator
'
' Description: "Microsoft ConfigMgr 2007 System Health Validator" computer attribute.
' Checks for installation of SMS System Health Validator.
'
' Parameters: None
'
' Returns: True if registry key SOFTWARE\Microsoft\SMS\Operations
' Management\SMS Server Role\System Health Validator exists.
'=============
Public Function AttributeValue_MicrosoftSMSv4SystemHealthValidator()

AttributeValue_MicrosoftSMSv4SystemHealthValidator = g_oUtil.CheckRegistryKeyExists(g_oUtil.HKEY_LOCAL_MACHINE, g_oUtil.REG_KEY_SMS_SERVER_OPMGMT_SYSTEM_HEALTH_VALIDATOR)

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_SERVER_OPMGMT_SMS_SERVER_ROLE
Public REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE

Public REG_PATH_SMS_SERVER_OPMGMT_COMPONENTS
Public REG_PATH_SMS_SERVER_OPMGMT_COMPONENTS_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_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_FALLBACK_STATUS_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_MANAGEMENT_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_PXE_SERVICE_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_REPORTING_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_SERVER_LOCATOR_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_SITE_SERVER
Public REG_KEY_SMS_SERVER_OPMGMT_SQL_SERVER
Public REG_KEY_SMS_SERVER_OPMGMT_SOFTWARE_UPDATE_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_STATE_MIGRATION_POINT
Public REG_KEY_SMS_SERVER_OPMGMT_SYSTEM_HEALTH_VALIDATOR

Public REG_KEY_SMS_SERVER_OPMGMT_COMP_SMS_MP_DEVICE_MANAGER

Public REG_KEY_SMS_SERVER_PROVIDERS

'Registry key value name constants
Public REG_VALUE_SERVICES_DISPLAY_NAME

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
Public REG_VALUE_SMS_SERVER_SITE_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 + "\"

If (CheckWow64RegistryKeyExists() = True) Then
REG_PATH_SMS = "SOFTWARE\Wow6432Node\Microsoft\SMS"
Else
REG_PATH_SMS = "SOFTWARE\Microsoft\SMS"
End If

REG_PATH_SMS_BASE = 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_OPMGMT_COMPONENTS = REG_PATH_SMS_BASE + "Operations Management\Components"
REG_PATH_SMS_SERVER_OPMGMT_COMPONENTS_BASE = REG_PATH_SMS_SERVER_OPMGMT_COMPONENTS + "\"

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_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_FALLBACK_STATUS_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Fallback Status Point"
REG_KEY_SMS_SERVER_OPMGMT_MANAGEMENT_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Management Point"
REG_KEY_SMS_SERVER_OPMGMT_PXE_SERVICE_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS PXE Service Point"
REG_KEY_SMS_SERVER_OPMGMT_REPORTING_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Reporting Point"
REG_KEY_SMS_SERVER_OPMGMT_SERVER_LOCATOR_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Server Locator 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_SOFTWARE_UPDATE_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS Software Update Point"
REG_KEY_SMS_SERVER_OPMGMT_STATE_MIGRATION_POINT = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS State Migration Point"
REG_KEY_SMS_SERVER_OPMGMT_SQL_SERVER = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS SQL Server"
REG_KEY_SMS_SERVER_OPMGMT_SYSTEM_HEALTH_VALIDATOR = REG_PATH_SMS_SERVER_OPMGMT_SMS_SERVER_ROLE_BASE + "SMS System Health Validator"

REG_KEY_SMS_SERVER_OPMGMT_COMP_SMS_MP_DEVICE_MANAGER = REG_PATH_SMS_SERVER_OPMGMT_COMPONENTS_BASE + "SMS_MP_DEVICE_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_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"
REG_VALUE_SMS_SERVER_SITE_TYPE = "Site 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

'=============
' Function: CheckWow64RegistryKeyExists
' Description: Used to check existence of registry key
'
' HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
'
' Parameters: None
' Returns: True if the registry key exists else false.
'=============
Public Function CheckWow64RegistryKeyExists()

Dim oReg
Dim bGranted
Dim strKeyPath
Dim HKEY_LOCAL_MACHINE
Dim KEY_QUERY_VALUE

ScriptContext.Echo "Checking for Wow64 registry key."

'Get registry provider object
ScriptContext.Echo "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
HKEY_LOCAL_MACHINE = &amp;H80000002
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\SMS"
KEY_QUERY_VALUE = &amp;H1

if oReg.CheckAccess(HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, bGranted) = 0 Then
ScriptContext.Echo "Wow64 is present on this computer; found registry key : " + strKeyPath
CheckWow64RegistryKeyExists = bGranted
Else
ScriptContext.Echo "Wow64 is not present on this computer; could not access registry key : " + strKeyPath
CheckWow64RegistryKeyExists = False
End If

Set oReg = Nothing

End Function

'=============
' Function: 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

'=============
' Function: 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

'=============
' Function: 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


'******************************************************************************
' Name: GetErrorString
'
' Purpose: Attempts to find the description for an error if an error with
' no description is passed in.
'
' Parameters: oErr The error object
'
' Returns: String, the description for the error. (Includes the error code.)
'
Function GetErrorString(oErr)

Dim lErr
Dim strErr


lErr = oErr
strErr = oErr.Description

On Error Resume Next


If 0 &gt;= Len(strErr) Then

'If we don't have an error description, then check to see if the
'error is a 0x8007xxxx error. If it is, then look it up.
'===============================================================

Const ErrorMask = &amp;HFFFF0000
Const HiWord8007 = &amp;H80070000
Const LoWordMask = 65535 ' This is equivalent to 0x0000FFFF

If (lErr And ErrorMask) = HiWord8007 Then

'Attempt to use 'net helpmsg' to get a description for the error.
'================================================================

Dim oShell
Set oShell = CreateObject("WScript.Shell")

If Err = 0 Then

Dim oExec
Set oExec = oShell.Exec("net helpmsg " &amp; (lErr And LoWordMask))

Dim strMessage, i
Do
strMessage = oExec.stdout.ReadLine()
i = i + 1
Loop While (Len(strMessage) = 0) And (i &lt; 5)

strErr = strMessage

End If

End If

End If

GetErrorString = vbCrLf &amp; "The error returned was: '" &amp; strErr &amp; "' " &amp; lErr &amp; " (0x" &amp; Hex(lErr) &amp; ")"

End Function


'******************************************************************************
' Name: ScriptError
'
' Purpose: To generate a warning about a runtime script error.
'
' Parameters: strError The description of the error
'
' Returns: Nothing
'
Sub ScriptError(strError)

LogEvent EVENT_ID_SCRIPTERROR, EVENT_TYPE_WARNING, "encountered a runtime error." &amp; vbCrLf &amp; "Failed to " &amp; strError

End Sub


'******************************************************************************
' Name: LogEvent
'
' Purpose: To generate a MOM event
'
' Parameters: lEventID The event code
' lEventType The severity of the event
' strMessage The message to include in the event
'
' Returns: Nothing
'
Sub LogEvent(lEventID, lEventType, strMessage)

Dim oEvent


On Error Resume Next

Set oEvent = ScriptContext.CreateEvent

oEvent.EventNumber = lEventID
oEvent.EventType = lEventType
oEvent.Message = "The script '" &amp; ScriptContext.Name &amp; "' running under processing rule '" &amp; ScriptContext.ProcessingRule.Name &amp; "' " &amp; strMessage

ScriptContext.Submit oEvent

End Sub


'******************************************************************************
' Name: IsEventTracingEnabled
'
' Purpose: Returns the state of the EventTracingEnabled registry setting.
' This setting is directs scripts raise additional tracing MOM
' events i.e. start and completion events.
'
' Checks for the EventTracingEnabled registry value under the
' following registry paths. If the DWORD values exists, it is read.
'
' HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft Operations Manager
' HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft Operations Manager
'
' Parameters: None
'
' Returns: True if the value exists and is set to 1 else False.
'
Function IsEventTracingEnabled()

Dim strError
Dim lEventTracingEnabled

Dim objShell


On Error Resume Next


Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "Checking EventTracingEnabled registry value.")

'Create the WSH Shell object for accessing the registry.
'=======================================================

Set objShell = CreateObject("WScript.Shell")

If Err.number &lt;&gt; 0 Then
IsEventTracingEnabled = False
Exit Function
End If

'Read the EventTracingEnabled value from under the MOM key.
'==========================================================

lEventTracingEnabled = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\EventTracingEnabled")

If IsEmpty(lEventTracingEnabled) Then

lEventTracingEnabled = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft Operations Manager\EventTracingEnabled")

End If

'Return the appropriate value.
'=============================

If IsEmpty(lEventTracingEnabled) Then

strError = GetErrorString(Err)
Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "Failed to read EventTracingEnabled registry value." &amp; strError)

IsEventTracingEnabled = False

Else

Call g_oUtil.LogMessage(g_oUtil.DBG_TRACE, "EventTracingEnabled registry value is '" &amp; lEventTracingEnabled &amp; "'.")

If (lEventTracingEnabled = 1) Then
IsEventTracingEnabled = True
Else
IsEventTracingEnabled = False
End If

End If

Set objShell = Nothing

Err.Clear

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