MOMDiscoveryData.CreateClassInstance Method
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
Creates a new monitoring class instance.
MOMDiscoveryData.CreateClassInstance(bstrClassType)
Parameters
Parameter | Type | Description |
---|---|---|
bstrClassType |
String |
The class type. |
Return Value
Type | Description |
---|---|
Object |
Returns a new instance of the MOMClassInstance object. |
Remarks
The CreateClassInstance method instantiates a class within the management pack or another referenced management pack, allowing it to be discovered.
After an object is created, properties can be set. After the properties are set, the instance must be added to the discovery data by using the MOMDiscoveryData.AddInstance method, and either the MOMScriptAPI.Return method or the MOMScriptAPI.ReturnItems method must be called to submit the discovery data to Operations Manager.
Requirements
Platforms: Requires Windows Server 2003, Windows Vista, or Windows Server 2008
Version: Requires Operations Manager 2007
Example
The following example code creates a discovery data class instance as identified by the input parameters. Another example can be seen in the CreateDiscoveryData method.
Option Explicit
Dim oArgs
Set oArgs = WScript.Arguments
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")
Dim SourceType, SourceId, ManagedEntityId, TargetComputer
SourceType = 0
' SourceId is the GUID of the discovery object that runs the script.
SourceId = oArgs(0)
' ManagedEntityId is the GUID of the computer class that is targeted by the script.
ManagedEntityId = oArgs(1)
' TargetComputer is the Fully Qualified Domain Name
' of the computer that is targeted by the script. The FQDN
' is within Arg(2) of the command prompt.
TargetComputer = oArgs(2)
Dim oDiscoveryData, oInst
Set oDiscoveryData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
' Create the application instance.
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Demo.Scripting.Appy']$")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='Microsoft.Demo.Scripting.AppY']/Name$", "ApplicationName")
Call oDiscoveryData.AddInstance(oInst)
' Submit the application data to the Operations Manager database.
Call oAPI.Return(oDiscoveryData)
See Also
Reference
MOMDiscoveryData Object
MOMDiscoveryData.CreateRelationshipInstance Method