Service Manager Management Server Properties Discovery

Microsoft.SystemCenter.ServiceManager.SmManagementServerProperties.Discovery (Discovery)

Discovers properties of Microsoft System Center Service Manager.

Knowledge Base article:

Summary

This discovery populates Service Manager properties.Discovery runs immedietely after being imported followed by another run at 13:00, the sync time. Following this it runs at a 24 hour interval. Sync time,frequency as well as timeout can be changed.Changing arguments is not recommended.

Element properties:

TargetMicrosoft.SystemCenter.ServiceManager.SmManagementServer
EnabledTrue
Frequency86400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Microsoft.SystemCenter.ServiceManager.DatabaseWriteActionAccount

Source Code:

<Discovery ID="Microsoft.SystemCenter.ServiceManager.SmManagementServerProperties.Discovery" Enabled="true" Target="SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer.2010"/>
<DiscoveryClass TypeID="SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer.2012"/>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="SM!Microsoft.SystemCenter.ServiceManager.DatabaseWriteActionAccount" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime>01:00</SyncTime>
<ScriptName>ManagementServerPropertyDiscovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="SM!Microsoft.SystemCenter.ServiceManager.ManagementServer"]/Version$</Arguments>
<ScriptBody><Script>
'Copyright (c) Microsoft Corporation. All rights reserved.

'*************************************************************************
' $ScriptName: "GetSqlDriverName" $
'
' Purpose: This script is used to get SQL Driver name.
'
' $File: GetSqlDriverName.vbs $
'*************************************************************************
Option Explicit

Function GetSqlDriverName
Dim oAPI1, oReg
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Dim strComputer, strDriverPath, strKeyPath, intValue, strValueName,arrSubKeys,oSubkey,strNewKeyPath,intDotIndex
strComputer = "."
strDriverPath="SQLOLEDB"
Set oReg=GetObject("winmgmts:\\" &amp; _
strComputer &amp; "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each oSubkey In arrSubKeys
intValue = InStr(oSubkey, "SQL Server Native Client")
if intValue &lt;&gt; 0 Then
strValueName = "Driver"
strNewKeyPath = strKeyPath&amp;"\"&amp;oSubkey
oReg.GetStringValue HKEY_LOCAL_MACHINE, strNewKeyPath, strValueName , strDriverPath
strDriverPath = Mid (strDriverPath, InStrRev(strDriverPath, "\")+1)
intDotIndex = InStr(strDriverPath, ".")
strDriverPath = Left(strDriverPath , intDotIndex-1)
end if
Next
GetSqlDriverName = strDriverPath
End Function
'*************************************************************************
' ScriptName: ManagementServerPropertyDiscovery.vbs
'
' Purpose - Populate properties of SM Management Server
'
' Parameters - 0 - discovery id
' 1 - Target managed entity id
' 2 - Host Computer Principal Name
' 3 - Version
'*************************************************************************
SetLocale("en-us")
On Error Resume Next

Dim oAPI, sourceId, managedEntityId, hostCompPrincipalName, discoveryData, serverRunningWorkflows, isRunningWorkflows, version

Set oAPI = CreateObject("Mom.ScriptAPI")

sourceId = WScript.Arguments(0)
managedEntityId = WScript.Arguments(1)
hostCompPrincipalName = WScript.Arguments(2)
version = WScript.Arguments(3)

'Creating discovery data
Call oAPI.LogScriptEvent("ManagementServerPropertyDiscovery.vbs", 3000, 4, "Starting discovery of Service Manager Management Server Properties.")

Set discoveryData = oAPI.CreateDiscoveryData(0, sourceId, managedEntityId)

'Get management group name from registry
Dim oReg, iResult, arrSubKeys, managementGroupName, oMgtServer, smDbHostName, smDbName
Set oReg = GetObject("winmgmts:\\" &amp; hostCompPrincipalName &amp; "\root\default:StdRegProv")
If Err &lt;&gt; 0 Then
Call oAPI.LogScriptEvent("ManagementServerPropertyDiscovery.vbs", 3000, 4, "Unable to bind to WMI registry provider on " &amp; hostCompPrincipalName &amp; ". Terminating Discovery.")
Call oAPI.Return(discoveryData)
WScript.Quit
End if
Const HKLM = &amp;H80000002

If version = "2010" or version = "2012" then
iResult = oReg.Enumkey(HKLM, "SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Server Management Groups", arrSubKeys)
If iResult = 0 then
managementGroupName = arrSubKeys(0)
iResult = oReg.GetStringValue(HKLM, "SOFTWARE\Microsoft\System Center\2010\Common\Database", "DatabaseServerName", smDbHostName)
If iResult = 0 then
iResult = oReg.GetStringValue(HKLM, "SOFTWARE\Microsoft\System Center\2010\Common\Database", "DatabaseName", smDbName)
If iResult = 0 then
'Instantiate Management Server Class
Call oAPI.LogScriptEvent("ManagementServerPropertyDiscovery.vbs", 3000, 4, "Discovered SCSM " &amp; version &amp; " Management Server Properties.")

If version = "2010" then
Set oMgtServer = discoveryData.CreateClassInstance("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer.2010']$")
ElseIf version = "2012" then
Set oMgtServer = discoveryData.CreateClassInstance("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer.2012']$")
End If
Call oMgtServer.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.ManagementServer']/ManagementGroupName$", managementGroupName)
Call oMgtServer.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer']/SmDbHostName$", smDbHostName)
Call oMgtServer.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer']/SMDbName$", smDbName)
Call oMgtServer.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",hostCompPrincipalName)

Dim connectionString, cnADOConnection, oResults,oQuery,sourceName, strDriverName
strDriverName = GetSqlDriverName
connectionString = "Provider=" &amp; strDriverName &amp; "; Data Source=" &amp; smDbHostName &amp; "; Trusted_Connection=Yes; Initial Catalog=" &amp; smDbName &amp; ";"
Set cnADOConnection = CreateObject("ADODB.Connection")
cnADOConnection.Open connectionString
cnADOConnection.CommandTimeout = 300
oQuery = "select CONVERT(nvarchar(4000),B.Name) as ServerName from ScopedInstanceTargetClass SCT inner join ManagedType MT on MT.ManagedTypeId = SCT.ManagedTypeId inner join BaseManagedEntity B on B.BaseManagedEntityId = SCT.ScopedInstanceId where MT.TypeName ='Microsoft.SystemCenter.WorkflowTarget'"
Set oResults = CreateObject("ADODB.Recordset")
oResults.Open oQuery, cnADOConnection, 3, 3

If oResults.State &lt;&gt; 0 and oResults.RecordCount &gt; 0 Then
Do Until oResults.EOF
serverRunningWorkflows = oResults.Fields("ServerName")
oResults.MoveNext
Loop
End If
If oResults.State &lt;&gt; 0 Then
oResults.Close
End If
cnADOConnection.Close

if(isEmpty(serverRunningWorkflows)) Then
serverRunningWorkflows = ""
End If

If LCase(hostCompPrincipalName) = LCase(serverRunningWorkflows) then
isRunningWorkflows = true
Else
isRunningWorkflows = false
End If
Call oMgtServer.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.SmManagementServer']/isRunningWorkflows$",isRunningWorkflows)
Call discoveryData.AddInstance(oMgtServer)
End If
End If
End If
End If

Call oAPI.Return(discoveryData)
Call oAPI.LogScriptEvent("ManagementServerPropertyDiscovery.vbs", 3000, 4, "Finishined Discovering SCSM " &amp; version &amp;" Management Server Properties.")
WScript.Quit


</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>