Microsoft Dynamics CRM 4.0 Server Discovery

Microsoft.Dynamics.CRM.4.0.CrmServerDiscovery (Discovery)

This object discovery discovers all instances of Dynamics CRM 4.0 Servers running on Windows Servers.

Knowledge Base article:

Summary

This object discovery discovers all instances of Dynamics CRM 4.0 Servers running on Windows Servers. This discovery creates an instance for each Dynamics CRM 4.0 server role. The following Dynamics CRM 4.0 server roles are discovered by this object: Web Application Server, SDK Server, Discovery Service, Help Server, and Asynchronous Processing Service.

This discovery leverages the script Microsoft.Dynamics.Crm.Discovery.vbs to create instances for each server role. If discovery does not find all expected objects, review the System Center Operations Manager event log for errors.

Element properties:

TargetMicrosoft.Windows.Computer
EnabledTrue
Frequency36000
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.Dynamics.CRM.4.0.CrmServerDiscovery" Enabled="true" Target="Windows!Microsoft.Windows.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Asynchronous_Processing_Service_Server">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Deployment_Service_Server">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Discovery_Service_Server">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Help_Servers">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_SDK_Servers">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Web_App_Servers">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="Windows!Microsoft.Windows.ComputerHostsComputerRole"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>36000</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.Dynamics.CRM.4.0.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>Option Explicit
SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 3 Then
WScript.Quit -1
End If

Dim SourceID, ManagedEntityId, TargetComputer
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)

Dim oAPI, oDiscoveryData, oInst
Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)

Function GetRoles(strKey, oReg)
On Error Resume Next
Dim serverRoles
serverRoles = 0
serverRoles = oReg.RegRead(strKey)
GetRoles = serverRoles
End Function

Sub CreateInstance(strClass, oDiscData, strTarget)
Dim oInstance
set oInstance = oDiscData.CreateClassInstance(strClass)
call oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTarget)
call oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strTarget)
call oDiscData.AddInstance(oInstance)
End Sub

Dim strServerRoles, roles, oRegistry
Set oRegistry = CreateObject("WScript.Shell")
strServerRoles = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\roles"
roles = GetRoles(strServerRoles, oRegistry)

If roles &lt;&gt; 0 Then
Dim WebApp, Async, Disc, Sdk, Help, DeploySdk
WebApp = 1
Async = 2
Disc = 8
Sdk = 32768
Help = 262144
DeploySdk = 2097152

Dim strWebApp, strAsync, strDisc, strSdk, strHelp, strDeploySdk, strIIS, strCommon
strWebApp = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Web_App_Servers']$"
strAsync = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Asynchronous_Processing_Service_Server']$"
strDisc = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Discovery_Service_Server']$"
strSdk = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_SDK_Servers']$"
strHelp = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Help_Servers']$"
strDeploySdk = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Deployment_Service_Server']$"
strIIS = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_IIS_Servers']$"
strCommon = "$MPElement[Name='Microsoft.Dynamics.CRM.4.0.Microsoft_CRM_4_Common']$"

Dim isIISbasedRole
isIISbasedRole = 0

If (WebApp And roles) Then
call CreateInstance(strWebApp, oDiscoveryData, TargetComputer)
isIISbasedRole = 1
End If

If (Async And roles) Then
call CreateInstance(strAsync, oDiscoveryData, TargetComputer)
End If

If (Disc And roles) Then
call CreateInstance(strDisc, oDiscoveryData, TargetComputer)
isIISbasedRole = 1
End If

If (Sdk And roles) Then
call CreateInstance(strSdk, oDiscoveryData, TargetComputer)
isIISbasedRole = 1
End If

If (Help And roles) Then
call CreateInstance(strHelp, oDiscoveryData, TargetComputer)
isIISbasedRole = 1
End If

If (DeploySdk And roles) Then
call CreateInstance(strDeploySdk, oDiscoveryData, TargetComputer)
isIISbasedRole = 1
End If

If (isIISbasedRole = 1) Then
call CreateInstance(strIIS, oDiscoveryData, TargetComputer)
End If

call CreateInstance(strCommon, oDiscoveryData, TargetComputer)

End If

Call oAPI.Return(oDiscoveryData)</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>