Essentials Managed Computer VMM Agent Discovery

Microsoft.SystemCenter.Essentials.VMM.EssentialsManagedComputerVMMAgentDiscovery (Discovery)

Element properties:

TargetMicrosoft.SystemCenter.VirtualMachineManager.2008.Agent
EnabledTrue
Frequency86400
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.SystemCenter.Essentials.VMM.EssentialsManagedComputerVMMAgentDiscovery" Enabled="onEssentialMonitoring" Target="VMM2008!Microsoft.SystemCenter.VirtualMachineManager.2008.Agent" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="SCEInternal!Microsoft.SystemCenter.Essentials.EssentialsManagedComputer"/>
<DiscoveryClass TypeID="VMM2008!Microsoft.SystemCenter.VirtualMachineManager.2008.Agent"/>
<DiscoveryRelationship TypeID="Microsoft.SystemCenter.Essentials.EssentialsManagedComputerContainsVMMAgent"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverVMMAgent.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>
'****************************************************************************
'Copyright (c) Microsoft Corporation. All rights reserved.

' Parameters that should be passed to this script
' 0 MPElement ID ($MPElement$)
' 1 Target Id for ME this rule is running against ($Target/Id$)
' 2 Computer (FQDN)
'****************************************************************************

Option Explicit

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt;&gt; 3 Then
Quit()
End If

Dim SourceID, ManagedEntityId, TargetComputer

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)

Dim oAPI, oDiscoveryData

'Create Mom ScriptAPI object
Set oAPI = MOMCreateObject("MOM.ScriptAPI")

'Create Discovery data object
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)

If DoDiscovery(TargetComputer, oDiscoveryData) &gt;= 0 Then
Call oAPI.Return(oDiscoveryData)
Else
Quit()
End If

' Does the actual discovery
Function DoDiscovery(ByVal sTargetComputer, ByVal oDisc)
Dim oEssentialsAgentInstance, oVmmAgentInstance, oRelCon

'' Discover Essentials Managed Computer
Set oEssentialsAgentInstance = oDisc.CreateClassInstance("$MPElement[Name='SCEInternal!Microsoft.SystemCenter.Essentials.EssentialsManagedComputer']$")
Call oEssentialsAgentInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sTargetComputer)
Call oDisc.AddInstance(oEssentialsAgentInstance)

'' Discover VMM Agent
Set oVmmAgentInstance = oDisc.CreateClassInstance("$MPElement[Name='VMM2008!Microsoft.SystemCenter.VirtualMachineManager.2008.Agent']$")
Call oVmmAgentInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sTargetComputer)
Call oDisc.AddInstance(oVmmAgentInstance)

'' Discover Relationship
Set oRelCon = oDisc.CreateRelationshipInstance("$MPElement[Name='Microsoft.SystemCenter.Essentials.EssentialsManagedComputerContainsVMMAgent']$")
oRelCon.Source = oEssentialsAgentInstance
oRelCon.Target = oVmmAgentInstance
Call oDisc.AddInstance(oRelCon)

DoDiscovery = 0
End Function

'*************************************************************************
Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile
Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub
Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = m_lNumber
End Property
Public Property Get Source()
Source = m_sSource
End Property
Public Property Get Description()
Description = m_sDescription
End Property
Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class

'*************************************************************************

Function ThrowScriptErrorNoAbort(ByVal sMessage, ByVal oErr)
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'*************************************************************************
Dim sErrDescription, sErrNumber
sErrDescription = oErr.Description
sErrNumber = oErr.Number

End Function

'*************************************************************************
Function ThrowScriptError(Byval sMessage, ByVal oErr)
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'*************************************************************************
On Error Resume Next
ThrowScriptErrorNoAbort sMessage, oErr
Quit()
End Function
'*************************************************************************

Function MomCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error

On Error Resume Next
Set MomCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0

If oError.Number &lt;&gt; 0 Then ThrowScriptError "Unable to create automation object '" &amp; sProgramId &amp; "'", oError
End Function

'*************************************************************************
Function Quit()

WScript.Quit()

End Function

'****************************************************************************
</Script></ScriptBody>
<TimeoutSeconds>60</TimeoutSeconds>
</DataSource>
</Discovery>