MOMScriptAPI.CreatePropertyBag Method
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
Creates a new MOMPropertyBag object, which is used to temporarily store operations data (such as discovery, event, alert, or performance data) as a collection of name-value pairs.
MOMScriptAPI.CreatePropertyBag()
Return Value
Type | Description |
---|---|
Object |
A new instance of the MOMPropertyBag object. |
Remarks
A script uses a property bag to store output data that will be used by subsequent modules. Four possible uses of property bags are:
Map data to a performance point and store in the database.
Map data to an event and store in the database.
Use data to evaluate state as part of a monitor.
Map data to an alert and store in the database.
To create a MOMPropertyBag object that is to be mapped to a specific type of data (discovery, event, alert, or performance data), use the CreateTypedPropertyBag method.
Requirements
Platforms: Requires Windows Server 2003, Windows Vista, or Windows Server 2008
Version: Requires Operations Manager 2007
Example
This example creates a MOMPropertyBag object and adds a name-value pair by using the target computer and the time to ping that computer. A single script can create a single property bag. However, within the property bag any number of name-value pairs can be created.
Option Explicit
Dim oArgs
Set oArgs = WScript.Arguments
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")
' Ping the target computer.
Dim targetComputer
' targetComputer is the Fully Qualified Domain Name
' of the computer targeted by the script. The FQDN
' is within Arg(0) of the command prompt.
targetComputer = oArgs(0)
Dim objPing, objStatus, timeToPing, computername
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("Select * From Win32_PingStatus where address = '"_
& targetComputer & "'")
For Each objStatus in objPing
timeToPing = objStatus.ResponseTime
computername = objStatus.Address
Next
'
' Create a MOM Property bag and add the target computer with
' the ping time as a value pair.
Dim oMOMBag
Set oMOMBag = oAPI.CreatePropertyBag()
Call oMOMBag.AddValue(targetComputer, timeToPing)
' Submit the computer name and ping response time
' as performance data to the Operations Manager database.
Call oAPI.Return(oMOMBag)
See Also
Reference
MOMScriptAPI Object
MOMPropertyBag Object
MOMScriptAPI.CreateTypedPropertyBag Method