Scripting Overview

Microsoft Operations Manager 2000 (MOM) provides scripting capabilities for flexible, customized monitoring and response to events, alerts, and performance data. You can use the MOM scripting interface or standard Microsoft scripting languages to create scripts that MOM can implement. Scripts can extend MOM event management functions and provide additional data collection capabilities. MOM can also implement response scripts for events or alerts or do so on a scheduled basis.

The MOM scripting feature allows you to extend the capabilities of processing rules and provide specialized actions to respond to an event, alert, or performance threshold. Rules can also be configured to run on a scheduled basis.

MOM can run scripts in association with processing rules. Because MOM is rules-based, many problems can be detected and handled without using scripts. Scripting provides the advanced capabilities sometimes required for detecting and handling problems.

MOM uses Microsoft Active Scripting through scripts and Automation COM objects. MOM invokes Active Scripting, identifies the language of the user-provided script, and then calls the appropriate scripting engine. For scripts that use either VBScript or JScript, the language is specified on the General tab of the script's Properties dialog box. For all other languages, the Custom setting must be selected and the script engine must be specified by adding a line (similar to the following example) to the first line of the script.

#!PerlScript

Including the shebang line will cause errors unless the Custom language type is used. To determine the appropriate name (ProgID) to use when calling a specific scripting engine component, consult the documentation for that script engine.

The custom scripting engine must be installed on all computers on which the script will run.

The script runs and interacts with MOM through Automation COM objects. The script can also use other Automation COM objects. You can write scripts using any active scripting language, including VBScript, JScript, and Perl.

Script developers should be aware that objects automatically provided to scripts running in the Windows Script Host environment, such as the WScript object, are not present in the MOM scripting runtime. The WScript object is only available to scripts executed by the Cscript.exe or Wscript.exe application. Calling the WScript.Echo method or other WScript methods in a MOM script will result in script errors. Similarly, MOM scripting objects are not meant to be used outside of the MOM scripting environment and runtime. Using MOM scripting objects in other environments, such as the Windows Script Host, is unsupported.

Note Note

Use of the objects described in the Helper objects section is strongly discouraged. In most cases, identical or similar functionality is available through existing Windows Management Instrumentation (WMI) classes or COM libraries included with Windows or other Microsoft products. For more information, see Using Operating System APIs in Scripts.

MOM scripts run within the MOM OnePoint service process. This means the script runs with the same account and the same security privileges that the OnePoint service uses.

Scripts are stored in the MOM database and distributed with processing rules by the Agent Manager. Management Pack modules can contain scripts created for a specific application or environment. Open the source code for scripts included with MOM Management Packs from the Scripts node of the MOM Administrator console. View the source code on the Script tab of the script's Properties dialog box.

Note Note

For developer-oriented information about creating custom Management Packs, programming reports, extending the MOM Administrator console, and creating connectors to other management products, see the documentation and code samples in the MOM Software Development Kit (SDK).

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


Debugging Scripts

Debugging Scripts with Microsoft Visual Studio .NET

Debug MOM scripts either from the local computer or a remote computer using Microsoft Visual Studio .NET. Once the debugger is connected to the OnePoint service, you can step through scripts, set breakpoints, view the call stack, examine variables and objects, and use other debugging features in the Visual Studio .NET development environment. You can debug scripts running on either the MOM Consolidator computer or an agent computer.

Installing Remote Debugging Components

To support remote debugging, install the full set of Visual Studio .NET debugging components on the computer running the script.

To install the remote debugging components on an agent computer or a Consolidator

  1. From the Visual Studio .NET CD or DVD, run Setup.
  2. In the Visual Studio .NET Setup window, click Remote Components Setup.
  3. On the Remote Component Setup page, scroll to the Full Remote Debugging support area, and then click Install Full.
  4. Click OK after the installation is complete.

Enabling Debugging

The default settings on the MOM Consolidator and agents do not support attaching a debugger to the running MOM scripts. You must enable debugging through the Windows registry.

For scripts that run on agent computers, enable debugging on each agent computer you are debugging. If a script runs on the Consolidator, enable debugging on the Consolidator computer. This also allows you to debug agent scripts running on the Consolidator.

To turn debugging on and specify which scripts you want to debug

  1. Run Windows Registry Editor (Regedit.exe).
  2. Browse to the HKEY_LOCAL_MACHINE\SOFTWARE\Mission Critical Software\OnePoint registry key.
  3. Change the value of the DebugEnabledScripts entry to specify the name of the script or scripts you want to debug. Wildcard expressions are supported for this setting. If DebugEnabledScripts does not already exist, create a new String entry for it.
  4. To enable debugging, change the value of the EnableActiveDebugging entry to 1. If EnableActiveDebugging does not already exist, create a new DWORD entry for it.

To disable debugging, change EnableActiveDebugging to 0.

Note Note

Disable debugging after you have finished troubleshooting the problem. Enabling debugging will decrease performance, and other users could attach debuggers to the OnePointService.exe process and lock threads for extended periods of time.

Attaching the Debugger to MOM

To attach the debugger to an agent or Consolidator

  1. Start the Visual Studio .NET integrated development environment.
  2. On the Tools menu, click Debug Processes.
  3. In the Processes dialog box, type the name of the computer running the scripts in the Name box.
  4. In the Available Processes list, select OnePointService.exe, and then click Attach. Debug scripts on only one agent at a time.
  5. In the Attach to Process window, select Script from the list of program types to debug, and then click OK. All other types should be cleared.
  6. In the Debugged Processes list, select the OnePointService.exe process, click Break, and then click Close to save settings.
  7. Wait for a script matching the DebugEnabledScripts registry value to run.

To end the debugging session and detach from the OnePoint service, press Shift+F5.

Debugging the Script

The first script matching the name or wildcard pattern specified in the DebugEnabledScripts registry entry opens in Visual Studio .NET. You can use the commands on the Debug menu. You can also view the data displayed in the various debugging windows, such as the Locals window and the Call Stack window. For more information about debugging with Visual Studio .NET, see Using the Debugger in the Visual Studio .NET documentation.

When debugging MOM scripts, use the following guidelines:

  • If script execution is paused for long periods of time as you debug the code, expect MOM to raise alerts indicating that your script did not run to completion in a timely manner. These alerts can be ignored while debugging.
  • If the other scripts do not match the DebugEnabledScripts registry key or you press the Step or Go button in the debugger, attaching the debugger locks the thread responsible for running your script until the debugging is complete. A locked script thread will not prevent other scripts from running using other available threads, but it does decrease performance.
  • If a second instance of a script is started before you finish debugging the first instance, the second instance is prevented from running if it must wait longer than five minutes for the first instance to complete. If any script is prevented from running because of a debugging session or other causes, a MOM alert is raised.
  • If you must restart the OnePoint service, first detach the debugger from the OnePoint process. Reattach the debugger to the new OnePoint process after it has started. If you do not explicitly detach the debugger, the debugger might not be aware that the service process has stopped.
  • If you step through a script that has opened in the debugger until it exits and the next script to open in the debugger is the same script, the debugger will break into the script. Press F5 (the Continue command) to complete its execution, unless you want to step through the script again.

For more information about testing MOM scripts, see the MOM SDK for documentation about the RunScript.exe utility.

See Also

Remote Debugging Setup, Using the Debugger


Types of Scripts

Scripts can run on the agent or Consolidator computer. Because agents can run using a local system account by default, scripts that run on the agent computer can only access information local to the agent computer.

Note Note

If a script must access a network resource that requires a particular security context, the OnePoint service on the computer on which the script will be executed must be configured to use an appropriate service account.

Scripts that run on the Consolidator computer can access stored state information in the Consolidator's ScriptState object. They do not have access to ScriptState objects created by agent computers. This is true even for the local agent on the Consolidator computer.

Scripts can run in response to a processing rule match or on a timed basis.

State Variables

As a response to a processing rule, you can manipulate the state variables that the script creates. You can then use these state variables in a script to determine the appropriate action to take.

Use state variables to perform multi-event correlation. A state variable can keep track of how many times an event has occurred on one or more monitored computers.

For example, you want to monitor logon attempts and page your administrator if an excessive number of logon failures occur within a given period across all computers in your enterprise. A high number of logon failures in a short time might indicate a distributed attempt to break into the network. You can create a processing rule to increment a state variable every time a logon failure occurs. This increment is performed in highly optimized code rather than in a script and has minimal performance impact, even during the start of the business day when logon activity is very high. You can then run a script at regular intervals to check the state. If the number of failures is not excessive, the script resets the variable. If the number is excessive, the script pages your administrator.

Response Scripts

Response scripts answer an event, alert, or performance threshold. When you create a processing rule, you can specify a script to run in response to a processing rule match. Response scripts are synchronous, meaning that the agent or Consolidator waits for the script to complete before continuing to process the associated event, alert, or performance data.

Scripts could respond to an event, alert, or performance data with computer configuration changes. For example, using Windows Management Instrumentation (WMI), a script could change a computer configuration in response to an event. A company policy might prohibit employees from using dial-up networking. You can configure MOM to watch for an event indicating that dial-up networking is enabled on a computer. A script could respond by using WMI to turn off dial-up networking on that computer and then display a cautionary message to the computer user.

You can also create a processing rule that watches for successful logon events. When MOM processes a successful logon event, a script could analyze the number of failed logon events occurring on that computer in the last minute or so. If the number is high, the successful logon event might be indicative of a successful network security attack. If the script determines that the attack might have been successful, the script can generate a Security Breach alert and e-mail or page the network administrator.

Timed Scripts

Timed scripts are response scripts that run on a timed basis. They can run on the agent or Consolidator computer.

MOM can create timed events, and you can link a script as a response to a timed event. As an example, you could configure MOM to create an event that occurs every ten minutes. When the event occurs, the product could run a script that pings the Internet service provider (ISP) router. If the ISP connection is down, the script could create an alert that indicates the problem.


Configuring Modem Paging

While MOM provides a built-in paging notification option, the ModemPage.vbs script also provides a way to send paging notifications using a modem.

To set up hardware and MOM for modem paging

  1. Ensure that you have valid accounts with a third-party, modem-paging service provider.
  2. Connect the modem to the Consolidator computer and configure it.
  3. Ensure that the modem is functioning. You can use Microsoft Windows 2000 PhoneDialer or HyperTerminal to check modem functionality.
  4. Click the Send a Notification to a Notification Group response, and then type the following example custom command on the Command Format tab:
    cscript.exe ModemPage.vbs /SEND $Operator ID$ $SeverityNum$ "OnePoint Alert: $Description$"
    Note Note

    $SeverityNum$ is available only for alert processing rules. For an event or performance threshold processing rule, you must use a hard-coded priority number or leave the field blank to use the default priority.

  5. Ensure that the necessary operators have an operator ID from the third-party paging service provider. To receive a modem page, operators within the notification groups associated with the processing rules must have a paging service operator ID specified in the operator properties.

To configure the modem paging script on the Consolidator computer

  1. Assuming the default MOM installation folder was used, type the following at the command prompt:

    cd /d "%ProgramFiles%\Microsoft Operations Manager 2000\OnePoint"

  2. At the command prompt, type:

    cscript ModemPage.vbs /CONFIGURE

  3. On the Dial Parameter and Modem Device tab, select the correct modem.

  4. Click the Defined Services tab, and then click From File.

  5. In the C:\Program Files\Microsoft Operations Manager 2000\OnePoint folder, click Services.inf, and then click Open.

    • If the service provider you want to install is listed, click the service provider, and then click OK.

    • If the service provider you want to install is not listed, click New, enter the service provider details, and then click OK.

  6. Click the Send Options tab, ensure that the options you require are enabled, and then click OK.

  7. Set the paging script to use the service provider by entering the following at the command prompt:

    cscript ModemPage.vbs /SETPROVIDER "Serviceprovider"

    The SETPROVIDER switch is required. You must replace "Serviceprovider" with the actual name of the service provider you will be using.

  8. To send a test page, type the following at the command prompt:

    cscript ModemPage.vbs /SEND OperatorID [Priority] Messagetext

  Note  Note
Higher-priority-numbered pages are sent before lower-priority-numbered  pages.


Alert Object

Use the Alert object to manipulate alerts provided by MOM through the ScriptContext.Alert property and alerts created by the script with the ScriptContext.CreateAlert method.

Methods

Name | Description
GetCustomField | Gets the value of a user-defined custom field of an alert.
SetCustomField | Sets the value of a user-defined custom field of an alert.

Properties

Name | Description
AlertLevel | Gets the severity of the alert.
AlertSource | Gets the source of the alert.
Computer | Gets the name of the computer that raised the alert.
ComputerDomain | Gets the name of the domain to which the computer that raised the alert belongs.
Description | Gets the description of the alert.
ID | Gets the globally unique identifier (GUID) of the alert.
Name | Gets the name of the processing rule that raised an alert.
Owner | Gets the name of the alert owner.
ResolutionState | Gets the resolution state of the alert.
UTCTimeOfFirstEvent | Gets the date and time at which the first event that raised an alert occurred.
UTCTimeOfLastEvent | Gets the date and time at which the last event that raised an alert occurred.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext.CreateAlert Method, ScriptContext.Alert Property


GetCustomField Method

The GetCustomField method gets the value of a user-defined custom field of an alert.

[VBScript] Alert.GetCustomField(FieldNumber Integer)

Parameters

FieldNumber
Specifies the number of the user-defined custom field to get. Possible values for the FieldNumber parameter are 1, 2, 3, 4, and 5 to get the first through fifth custom fields, respectively.

Return Value

String

Examples

The following example shows how to get the value of the second user-defined custom field of an alert.

[VBScript]
Function GetAlertCustomData()
    Dim objAlert
    Dim strCustomField2

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert
        strCustomField2 = objAlert.GetCustomField(2)
        Set objAlert = Nothing
    End If

    GetAlertCustomData = strCustomField2
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


SetCustomField Method

The SetCustomField method sets the value of a user-defined custom field of an alert.

[VBScript] Alert.SetCustomField(FieldNumber Integer, FieldValue String)

Parameters

FieldNumber
Specifies the number of the user-defined custom field to set. Possible values for the FieldNumber parameter are 1, 2, 3, 4, and 5 to set the first through fifth custom fields, respectively.
FieldValue
Specifies the value to which to set the user-defined custom field of the alert.

Return Value

None

Examples

The following example shows how to store an array of values in the user-defined custom field of an alert.

[VBScript]
Function StoreArrayInCustomField(objAlert, intField, arrValues)
    Dim intIndex
    Dim strFieldValue

    For intIndex = LBound(arrValues) To UBound(arrValues)
        ' create a comma-separated string from the array
        strFieldValue = strFieldValue & CStr(arrValues(intIndex)) & ","
    Next

    objAlert.SetCustomField(intField, strFieldValue)

    StoreArrayInCustomField = strFieldValue
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


AlertLevel Property

The AlertLevel property gets the severity of the alert.

[VBScript] Alert.AlertLevel

Access

Read/Write

Return Value

Integer

Remarks

The following values are used to indicate the severity level for the alert.

Value | Description
10 | Success
20 | Information
30 | Warning
40 | Error
50 | Critical Error
60 | Security Breach
70 | Service Unavailable

Severity values are displayed using text descriptions, such as Service Unavailable or Success, in the MOM Administrator console or the Web console.

Examples

The following example shows how to create a new alert and set the Severity property to 50.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


AlertSource Property

The AlertSource property gets the source of the alert.

[VBScript] Alert.AlertSource

Access

Read/Write

Return Value

String

Remarks

The source of an alert is a user-defined name. If no name is defined, the event source is typically used.

Examples

The following example shows how to create a new alert and set the Source property to the strSource parameter.

[VBScript]
Function MakeAlert(strSource)
    Dim objAlert

    Set objAlert = ScriptContext.CreateAlert()
    objAlert.AlertSource = strSource
    Set MakeAlert = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


Computer Property

The Computer property gets the name of the computer that raised the alert.

[VBScript] Alert.Computer

Access

Read/Write

Return Value

String

Remarks

The Computer property is read/write when used with a new Alert object created with the ScriptContext.CreateAlert method. This property is read-only when used with an Alert object provided to the script by MOM.

Examples

The following example sets the Computer property based on the event that caused MOM to invoke the script. The Computer property is set to the name of the computer that logged the event.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


ComputerDomain Property

The ComputerDomain property gets the name of the domain to which the computer that raised the alert belongs.

[VBScript] Alert.ComputerDomain

Access

Read/Write

Return Value

String

Remarks

The ComputerDomain property is read/write when used with a new alert created with the ScriptContext.CreateAlert method. This property is read-only when used with an Alert object provided to the script by MOM.

Examples

The following example sets the ComputerDomain property based on the event that caused MOM to invoke the script. The ComputerDomain property is set to the name of the domain to which the computer that logged the event belongs.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


Description Property

The Description property gets the description of the alert.

[VBScript] Alert.Description

Access

Read/Write

Return Value

String

Remarks

The description of an alert is typically the description of the event that generated the alert.

Examples

The following example shows how to create a new alert and set the Description property.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


ID Property (Alert)

The ID property gets the globally unique identifier (GUID) of the alert.

[VBScript] Alert.ID

Access

Read-only

Return Value

String

Examples

The following example shows how to use GUIDs to check whether two alert objects represent the same alert.

[VBScript]
Function AreAlertsIdentical(objAlert1, objAlert2)
    Dim blnIsIdentical
    Dim strGUID1, strGUID2

    blnIsIdentical = False

    strGUID1 = objAlert1.ID
    strGUID2 = objAlert2.ID

    If (strGUID1 = strGUID2) Then
        blnIsIdentical = True
    End If

    AreAlertsIdentical = blnIsIdentical
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


Name Property

The Name property gets the name of the processing rule that raised an alert.

[VBScript] Alert.Name

Access

Read/Write

Return Value

String

Remarks

The Name property is read-only when used with an Alert object provided to the script by MOM. This property is read/write when used with a new Alert object created with the ScriptContext.CreateAlert method.

Examples

The following example sets the Name property based on the alert that caused MOM to invoke the script. The Name property is set to the name of the processing rule that raised the alert.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM SP1

See Also

Alert Object


Owner Property

The Owner property gets the name of the alert owner. The owner can be someone responsible for tracking and resolving the alert.

[VBScript] Alert.Owner

Access

Read/Write

Return Value

String

Examples

The following example shows how to create a new alert and set the Owner property to "[unassigned]".

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


ResolutionState Property

The ResolutionState property gets the resolution state of the alert.

[VBScript] Alert.ResolutionState

Access

Read/Write

Return Value

Integer

Remarks

Resolution state values are displayed using text descriptions, such as Open or Resolved, in the MOM Administrator console or the Web console.

The following ResolutionState values are used.

Value | Description
0 | New
85 | Acknowledged
170 | Level 1: Assigned to a help desk or local support
180 | Level 2: Assigned to a subject matter expert
190 | Level 3: Requires scheduled maintenance
200 | Level 4: Assigned to an external group or vendor
255 | Resolved

Examples

The following example shows how to create a new alert and set the ResolutionState property to 0.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


UTCTimeOfFirstEvent Property

The UTCTimeOfFirstEvent property gets the date and time at which the first event that raised an alert occurred.

[VBScript] Alert.UTCTimeOfFirstEvent

Access

Read-only

Return Value

Date

Remarks

The UTCTimeOfFirstEvent property is most useful when used with consolidated alerts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


UTCTimeOfLastEvent Property

The UTCTimeOfLastEvent property gets the date and time at which the last event that raised an alert occurred.

[VBScript] Alert.UTCTimeOfLastEvent

Access

Read-only

Return Value

Date

Remarks

The UTCTimeOfLastEvent property is most useful when used with consolidated alerts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Alert Object


Event Object

Use the Event object to manipulate events provided by MOM through the ScriptContext.Event property and events created by the script with the ScriptContext.CreateEvent method.

Methods

Name | Description
EventParameter | Gets an event parameter.
SetEventParameter | Sets the event parameters of a newly created event object.

Properties

Name | Description
Category | Gets the category of the event.
EventNumber | Gets the Windows NT and Windows 2000 event ID of the event.
EventSource | Gets the source of the event.
EventType | Gets the type of the event, such as Warning or Error.
LoggingComputer | Gets the name of the computer that logged the event.
LoggingDomain | Gets the logging domain of the event.
Message | Gets the description of the event.
MessageDLL | Gets the name of the message DLL that provides the event.
MessageDLLFileVersion | Gets the version number of the message DLL that provides the event.
SourceComputer | Gets the name of the computer that generated the event.
SourceDomain | Gets the source domain of the event.
UTCTime | Gets the date and time that the event occurred.
UserName | Gets the name of the Windows NT or Windows 2000 account that generated the event.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext.CreateEvent Method, ScriptContext.Event Property


EventParameter Method

The EventParameter method gets an event parameter.

[VBScript] Event.EventParameter(ID Long)

Parameters

ID
Specifies the event parameter to get.

Return Value

String

Examples

The following example shows how to get the first event parameter for the event provided to the script from MOM.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


SetEventParameter Method

The SetEventParameter method sets the event parameters of a newly created event object.

[VBScript] Event.SetEventParameter(Parameter String)

Parameters

Parameter
Specifies the value of the event parameter.

Return Value

String

Examples

The following example shows how to set the first and second event parameters for a newly created event object.

[VBScript]
Function SetParams(strParam1, strParam2)
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.SetEventParameter(strParam1)
    objEvent.SetEventParameter(strParam2)

    ScriptContext.Submit(objEvent)

    Set SetParams = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


Category Property

The Category property gets the category of the event.

[VBScript] Event.Category

Access

Read/Write

Return Value

String

Remarks

The category of an event is a Windows 2000 text string that describes the event, such as Server or Kernel.

The Category property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the Category property to Server.

[VBScript]
Function MakeEvent
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()
    objEvent.Category = "Server"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


EventNumber Property

The EventNumber property gets the Windows NT and Windows 2000 event ID of the event.

[VBScript] Event.EventNumber

Access

Return Value

Long

Remarks

The EventNumber property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the EventNumber property to 1349.

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


EventSource Property

The EventSource property gets the source of the event.

[VBScript] Event.EventSource

Access

Read/Write

Return Value

String

Remarks

The EventSource property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the EventSource property to "TestScript".

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


EventType Property

The EventType property gets the type of the event, such as Warning or Error.

[VBScript] Event.EventType

Access

Read/Write

Return Value

Long

Remarks

The EventType property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

The following table shows the values for the EventType property.

Value | Description
0 | Success
1 | Error
2 | Warning
4 | Information
8 | Audit Success
16 | Audit Failure

Examples

The following example shows how to create a new event and set the EventType property to Warning.

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


LoggingComputer Property

The LoggingComputer property gets the name of the computer that logged the event.

[VBScript] Event.LoggingComputer

Access

Read/Write

Return Value

String

Remarks

The LoggingComputer property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the LoggingComputer property.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    Set objSourceEvent = ScriptContext.Event
    Set objNewEvent = ScriptContext.CreateEvent()

    objNewEvent.LoggingDomain = "DOMAIN1"

    objNewEvent.UTCTime = objSourceEvent.UTCTime
    objNewEvent.UserName = objSourceEvent.UserName
    objNewEvent.SourceComputer = objSourceEvent.SourceComputer
    objNewEvent.Message = objSourceEvent.Message
    objNewEvent.MessageDLL = objSourceEvent.MessageDLL
    objNewEvent.LoggingComputer = objSourceEvent.LoggingComputer

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


LoggingDomain Property

The LoggingDomain property gets the logging domain of the event.

[VBScript] Event.LoggingDomain

Access

Read/Write

Return Value

String

Remarks

The LoggingDomain property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the LoggingDomain property to DOMAIN1.

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


Message Property

The Message property gets the description of the event.

[VBScript] Event.Message

Access

Read/Write

Return Value

String

Remarks

The Message property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example sets the Message property based on the event that caused MOM to invoke the script. The Message property is set to the description of the event.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    If (ScriptContext.IsEvent()) Then
        Set objSourceEvent = ScriptContext.Event
        Set objNewEvent = ScriptContext.CreateEvent()

        objNewEvent.LoggingDomain = "DOMAIN1"

        objNewEvent.UTCTime = objSourceEvent.UTCTime
        objNewEvent.UserName = objSourceEvent.UserName
        objNewEvent.SourceComputer = objSourceEvent.SourceComputer
        objNewEvent.Message = objSourceEvent.Message
        objNewEvent.MessageDLL = objSourceEvent.MessageDLL
        objNewEvent.LoggingComputer = objSourceEvent.LoggingComputer
    Else
        Set objNewEvent = Nothing
    End If

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


MessageDLL Property

The MessageDLL property gets the name of the message DLL that provides the event.

[VBScript] Event.MessageDLL

Access

Read/Write

Return Value

String

Remarks

The MessageDLL property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the MessageDLL property.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    Set objSourceEvent = ScriptContext.Event
    Set objNewEvent = ScriptContext.CreateEvent()

    objNewEvent.LoggingDomain = "DOMAIN1"

    objNewEvent.UTCTime = objSourceEvent.UTCTime
    objNewEvent.UserName = objSourceEvent.UserName
    objNewEvent.SourceComputer = objSourceEvent.SourceComputer
    objNewEvent.Message = objSourceEvent.Message
    objNewEvent.MessageDLL = objSourceEvent.MessageDLL
    objNewEvent.LoggingComputer = objNewEvent.LoggingComputer

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


MessageDLLFileVersion Property

The MessageDLLFileVersion property gets the version number of the message DLL that provides the event.

[VBScript] Event.MessageDLLFileVersion

Access

Read-only

Return Value

String

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


SourceComputer Property (Event)

The SourceComputer property gets the name of the computer that generated the event.

[VBScript] Event.SourceComputer

Access

Read/Write

Return Value

String

Remarks

The SourceComputer property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example sets the SourceComputer property based on the event that caused MOM to invoke the script. The SourceComputer property is set to the name of the computer that generated the event.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    Set objSourceEvent = ScriptContext.Event
    Set objNewEvent = ScriptContext.CreateEvent()

    objNewEvent.LoggingDomain = "DOMAIN1"

    objNewEvent.UTCTime = objSourceEvent.UTCTime
    objNewEvent.UserName = objSourceEvent.UserName
    objNewEvent.SourceComputer = objSourceEvent.SourceComputer
    objNewEvent.Message = objSourceEvent.Message
    objNewEvent.MessageDLL = objSourceEvent.MessageDLL
    objNewEvent.LoggingComputer = objSourceEvent.LoggingComputer

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


SourceDomain Property (Event)

The SourceDomain property gets the source domain of the event.

[VBScript] Event.SourceDomain

Access

Read/Write

Return Value

String

Remarks

The SourceDomain property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example shows how to create a new event and set the SourceDomain property to DOMAIN1.

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


UTCTime Property

The UTCTime property gets the date and time that the event occurred.

[VBScript] Event.UTCTime

Access

Read/Write

Return Value

Date

Remarks

The UTCTime property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example sets the UTCTime property based on the event that caused MOM to invoke the script. The UTCTime property is set to the time that the event occurred.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    Set objSourceEvent = ScriptContext.Event
    Set objNewEvent = ScriptContext.CreateEvent()

    objNewEvent.LoggingDomain = "DOMAIN1"

    objNewEvent.UTCTime = objSourceEvent.UTCTime
    objNewEvent.UserName = objSourceEvent.UserName
    objNewEvent.SourceComputer = objSourceEvent.SourceComputer
    objNewEvent.Message = objSourceEvent.Message
    objNewEvent.MessageDLL = objSourceEvent.MessageDLL
    objNewEvent.LoggingComputer = objSourceEvent.LoggingComputer

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


UserName Property (Event)

The UserName property gets the name of the Windows NT or Windows 2000 account that generated the event.

[VBScript] Event.UserName

Access

Read/Write

Return Value

String

Remarks

The UserName property is read-only when used with an event provided to the script by MOM. The property is read/write when used with a new event created with the ScriptContext.CreateEvent method.

Examples

The following example sets the UserName property of the new event to the same value as the original event sent in the parameter.

[VBScript]
Function MakeEventFromEvent()
    Dim objSourceEvent
    Dim objNewEvent

    Set objSourceEvent = ScriptContext.Event
    Set objNewEvent = ScriptContext.CreateEvent()

    objNewEvent.LoggingDomain = "DOMAIN1"

    objNewEvent.UTCTime = objSourceEvent.UTCTime
    objNewEvent.UserName = objSourceEvent.UserName
    objNewEvent.SourceComputer = objSourceEvent.SourceComputer
    objNewEvent.Message = objSourceEvent.Message
    objNewEvent.MessageDLL = objSourceEvent.MessageDLL
    objNewEvent.LoggingComputer = objSourceEvent.LoggingComputer

    Set objSourceEvent = Nothing

    Set MakeEventFromEvent = objNewEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Event Object


PerfData Object

Use the PerfData object to manipulate performance data provided by MOM through the ScriptContext.PerfData property and performance data created by the script with the ScriptContext.CreatePerfData method.

Properties

Name | Description
CounterName | Gets the name of the performance object counter used to report the performance data.
ID | Gets the GUID of the performance data.
InstanceName | Gets the name of the performance counter instance used to report the performance data.
ObjectName | Gets the name of the performance object for which the performance data was collected.
SampleUTCTime | Gets the date and time that the performance data was collected.
SourceComputer | Gets the name of the computer from which the performance data was collected.
SourceDomain | Gets the name of the domain to which the computer providing the performance data belongs.
Value | Gets the numeric value of the performance data.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext.CreatePerfData Method, ScriptContext.PerfData Property


CounterName Property

The CounterName property gets the name of the performance object counter used to report the performance data.

[VBScript] PerfData.CounterName

Access

Read/Write

Return Value

String

Remarks

The CounterName property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to access the name of the performance object counter.

[VBScript]
Function GetPerfCounterString(objPerfData)
    Dim strComputerName, strObjectName, strCounterName, strInstanceName
    Dim strCounter

    strComputerName = objPerfData.SourceComputer
    strObjectName = objPerfData.ObjectName
    strCounterName = objPerfData.CounterName
    strInstanceName = objPerfData.InstanceName

    strCounter = "\\" & strComputerName & "\" & _
                  strObjectName & "(" & strInstanceName & ")\" _
                  & strCounterName

    GetPerfCounterString = strCounter
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


ID Property (Performance Data)

The ID property gets the GUID of the performance data.

[VBScript] PerfData.ID

Access

Read-only

Return Value

String

Examples

The following example shows how to use the ID property to compare performance data objects.

[VBScript]
Function ArePerfDataObjectsIdentical(objPerfData1, objPerfData2)
    Dim blnIsIdentical
    Dim strGUID1, strGUID2

    blnIsIdentical = False

    strGUID1 = objPerfData1.ID
    strGUID2 = objPerfData2.ID

    If (strGUID1 = strGUID2) Then
        blnIsIdentical = True
    End If

    ArePerfDataObjectsIdentical = blnIsIdentical
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


InstanceName Property

The InstanceName property gets the name of the performance counter instance used to report the performance data.

[VBScript] PerfData.InstanceName

Access

Read/Write

Return Value

String

Remarks

The InstanceName property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to access the name of the performance counter instance used to report the performance data provided to the script by MOM.

[VBScript]
Function GetPerfCounterString(objPerfData)
    Dim strComputerName, strObjectName, strCounterName, strInstanceName
    Dim strCounter

    strComputerName = objPerfData.SourceComputer
    strObjectName = objPerfData.ObjectName
    strCounterName = objPerfData.CounterName
    strInstanceName = objPerfData.InstanceName

    strCounter = "\\" & strComputerName & "\" & _
                  strObjectName & "(" & strInstanceName & ")\" _
                  & strCounterName

    GetPerfCounterString = strCounter
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


ObjectName Property

The ObjectName property gets the name of the performance object for which the performance data was collected. Examples of performance objects are processes, sections of shared memory, and physical devices.

[VBScript] PerfData.ObjectName

Access

Read/Write

Return Value

String

Remarks

The ObjectName property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to access the name of the performance object of the data provided to the script by MOM.

[VBScript]
Function GetPerfCounterString(objPerfData)
    Dim strComputerName, strObjectName, strCounterName, strInstanceName
    Dim strCounter

    strComputerName = objPerfData.SourceComputer
    strObjectName = objPerfData.ObjectName
    strCounterName = objPerfData.CounterName
    strInstanceName = objPerfData.InstanceName

    strCounter = "\\" & strComputerName & "\" & _
                  strObjectName & "(" & strInstanceName & ")\" _
                  & strCounterName

    GetPerfCounterString = strCounter
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object, ScriptContext.CreatePerfData Method


SampleUTCTime Property

The SampleUTCTime property gets the date and time that the performance data was collected.

[VBScript] PerfData.SampleUTCTime

Access

Read/Write

Return Value

Date

Remarks

The SampleUTCTime property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to create new performance data and set the SampleUTCTime property.

[VBScript]
Function MakePerfDataFromEvent()
    Dim objPerfData, objEvent

    Set objPerfData = ScriptContext.CreatePerfData()

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event

        objPerfData.SourceDomain = objEvent.SourceDomain
        objPerfData.SourceComputer = objEvent.SourceComputer
        objPerfData.SampleUTCTime = objEvent.UTCTime
    Else
        Set objPerfData = Nothing
    End If

    Set objEvent = Nothing

    Set MakePerfDataFromEvent = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


SourceComputer Property (Performance Data)

The SourceComputer property gets the name of the computer from which the performance data was collected.

[VBScript] PerfData.SourceComputer

Access

Read/Write

Return Value

String

Remarks

The SourceComputer property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to create new performance data and set the SourceComputer property.

[VBScript]
Function MakePerfDataFromEvent()
    Dim objPerfData, objEvent

    Set objPerfData = ScriptContext.CreatePerfData()

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event

        objPerfData.SourceDomain = objEvent.SourceDomain
        objPerfData.SourceComputer = objEvent.SourceComputer
        objPerfData.SampleUTCTime = objEvent.UTCTime
    Else
        Set objPerfData = Nothing
    End If

    Set objEvent = Nothing

    Set MakePerfDataFromEvent = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


SourceDomain Property (Performance Data)

The SourceDomain property gets the name of the domain to which the computer providing the performance data belongs.

[VBScript] PerfData.SourceDomain

Access

Read/Write

Return Value

String

Remarks

The SourceDomain property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to create new performance data and set the SourceDomain property.

[VBScript]
Function MakePerfDataFromEvent()
    Dim objPerfData, objEvent

    Set objPerfData = ScriptContext.CreatePerfData()

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event

        objPerfData.SourceDomain = objEvent.SourceDomain
        objPerfData.SourceComputer = objEvent.SourceComputer
        objPerfData.SampleUTCTime = objEvent.UTCTime
    Else
        Set objPerfData = Nothing
    End If

    Set objEvent = Nothing

    Set MakePerfDataFromEvent = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


Value Property

The Value property gets the numeric value of the performance data.

[VBScript] PerfData.Value

Access

Read/Write

Return Value

Double

Remarks

The Value property is read-only when used with performance data provided to the script by MOM. The property is read/write when used with new performance data created with the ScriptContext.CreatePerfData method.

Examples

The following example shows how to check the performance data value to see if it is within a specified range.

[VBScript]
Function IsPerfDataWithinRange(objPerfData, dblMinValue, dblMaxValue)
    Dim blnIsInRange
    Dim dblValue

    blnIsInRange = False

    dblValue = objPerfData.Value

    If ((dblValue >= dblMinValue) And (dblValue <= dblMaxValue)) Then
        blnIsInRange =  True
    End If

    IsPerfDataWithinRange = blnIsInRange
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PerfData Object


ScriptContext Object

The ScriptContext object gets the MOM scripting objects. Use the ScriptContext object to access and manipulate MOM alerts, events, performance data, and variable sets. The ScriptContext object is automatically instantiated by the MOM scripting environment. The ScriptContext object can be considered the root object for MOM scripts. The ScriptContext object is capable of creating all of the other product objects by using methods, such as ScriptContext.CreateAlert, or through the return value of properties, such as the ScriptContext.Alert property.

Methods

Name | Description
CreateAlert | Generates a new Alert object.
CreateEvent | Generates a new Event object.
CreatePerfData | Generates a new PerfData object.
GetScriptState | Gets the ScriptState object.
IsAlert | Determines whether the object provided to the script by MOM is an Alert object.
IsEvent | Determines whether the object provided to the script by MOM is an Event object.
IsPerfData | Determines whether the object provided to the script by MOM is a PerfData object.
Submit | Submits an Alert, Event, or PerfData object to the MOM data stream.

Properties

Name | Description
Alert | Gets the Alert object that caused MOM to invoke the script.
Event | Gets the Event object that caused MOM to invoke the script.
Parameters | Gets a VarSet object that contains the parameters sent from MOM when the script was invoked.
PerfData | Gets the PerfData data object that caused MOM to invoke the script.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1


CreateAlert Method

The CreateAlert method generates a new Alert object.

[VBScript] ScriptContext.CreateAlert()

Parameters

None

Return Value

Object (Alert)

Remarks

The Alert object returned by this method is initially empty. After creating the new Alert object, assign a value to it using the ScriptContext.Alert property. The Alert object can then be sent to the MOM data stream using the ScriptContext.Submit method.

Examples

The following example shows how to generate a new Alert object.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, ScriptContext.Alert Property, ScriptContext.Submit Method, Alert Object


CreateEvent Method

The CreateEvent method generates a new Event object.

[VBScript] ScriptContext.CreateEvent()

Return Value

Object (Event)

Remarks

The Event object returned by this method is initially empty. After creating the new Event object, assign a value to it using the ScriptContext.Event property. The Event object can then be sent to the MOM data stream using the ScriptContext.Submit method.

Examples

The following example shows how to generate a new Event object.

[VBScript]
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, ScriptContext.Event Property, ScriptContext.Submit Method, Event Object


CreatePerfData Method

The CreatePerfData method generates a new PerfData object.

[VBScript] ScriptContext.CreatePerfData()

Parameters

None

Return Value

Object (PerfData)

Remarks

The PerfData object returned by this method is initially empty. After creating the new PerfData object, assign a value to it using the ScriptContext.PerfData property. The PerfData object can then be sent to the MOM data stream using the ScriptContext.Submit method.

Examples

The following example creates a PerfData object with the CreatePerfData method, populates the PerfData object the using PerfData object properties, and submits the PerfData object to the MOM data stream with the Submit method.

[VBScript]
Function MakeAndSubmitPerfData(strSourceComputer, lngValue)
    Dim objPerfData

    Set objPerfData = ScriptContext.CreatePerfData()

    'Populate perfdata
    objPerfData.SourceComputer = strSourceComputer
    objPerfData.Value = lngValue

    ScriptContext.Submit(objPerfData)

    Set MakeAndSubmitPerfData = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, ScriptContext.PerfData Property, ScriptContext.Submit Method, PerfData Object


GetScriptState Method

The GetScriptState method gets the ScriptState object.

[VBScript] ScriptContext.GetScriptState()

Parameters

None

Return Value

Object

Remarks

You can use the ScriptState object as a persistent store for script variables.

Examples

The following example shows how to access the ScriptState object.

[VBScript]
Function GetSavedVarSet(strVarSetName)
    Dim objScriptState
    Dim objVarSet

    Set objScriptState = ScriptContext.GetScriptState()
    Set objVarSet = objScriptState.GetSet(strVarSetName)

    Set objScriptState = Nothing

    Set GetSavedVarSet = objVarSet
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, ScriptState Object


IsAlert Method

The IsAlert method determines whether the object provided to the script by MOM is an Alert object.

[VBScript] ScriptContext.IsAlert()

Return Value

Long Integer

Examples

The following example shows how to determine whether the object provided to the script by MOM is an Alert object.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, Alert Object


IsEvent Method

The IsEvent method determines whether the object provided to the script by MOM is an Event object.

[VBScript] ScriptContext.IsEvent()

Return Value

Long Integer

Examples

The following example shows how to create an alert from the Event object that caused MOM to invoke the script.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, Event Object


IsPerfData Method

The IsPerfData method determines whether the object provided to the script by MOM is a PerfData object.

[VBScript] ScriptContext.IsPerfData()

Return Value

Long Integer

Examples

The following example shows how to determine whether the object provided to the script by MOM is a PerfData object.

[VBScript]
Function GetPerfData()
    Dim objPerfData

    If (ScriptContext.IsPerfData()) Then
        Set objPerfData = ScriptContext.PerfData
    Else
        Set objPerfData = Nothing
    End If

    Set GetPerfData = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, PerfData Object


Submit Method

The Submit method submits an Alert, Event, or PerfData object to the MOM data stream.

[VBScript] ScriptContext.Submit(oObject Object)

Parameters

oObject
Specifies the object to submit to the MOM data stream. It should be an Alert, Event, or PerfData object.

Return Value

None

Remarks

After creating an Alert, Event, or PerfData object with the CreateAlert, CreateEvent, or CreatePerfData method, you must call the Submit method for MOM to process the Alert, Event, or PerfData object.

Examples

The following example shows how to submit an Alert object to the MOM data stream.

[VBScript]
Function SubmitObject(objCreatedObject)
    Dim strObjectType

    strObjectType = TypeName(objCreatedObject)

    If ((strObjectType = "IEEMScriptAlert") Or _
        (strObjectType = "IEEMScriptEvent") Or _
        (strObjectType = "IEEMScriptPerfData")) Then
        ScriptContext.Submit(objCreatedObject)
    Else
        strObjectType = "Error, unknown object type: " & strObjectType
    End If

    SubmitObject = strObjectType
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object


Alert Property

The Alert property gets the Alert object that caused MOM to invoke the script.

[VBScript] ScriptContext.Alert

Access

Read/Write

Return Value

Object

Examples

The following example shows how to access the Alert object that caused MOM to invoke the script.

[VBScript]
Function CreateNewAlert()
    Dim objCreatedAlert
    Dim objAlert

    Set objCreatedAlert = ScriptContext.CreateAlert()

    If (ScriptContext.IsAlert()) Then
        Set objAlert = ScriptContext.Alert

        objCreatedAlert.Name = objAlert.Name
        objCreatedAlert.AlertLevel = 50
        objCreatedAlert.Owner = "[unassigned]"
        objCreatedAlert.ResolutionState = 0  ' New
    Else
        Set objCreatedAlert = Nothing
    End If

    Set objAlert = Nothing

    Set CreateNewAlert = objCreatedAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, Alert Object


Event Property

The Event property gets the Event object that caused MOM to invoke the script.

[VBScript] ScriptContext.Event

Access

Read/Write

Return Value

Object

Examples

The following example shows how to create an alert from the Event object that caused MOM to invoke the script.

[VBScript]
Function MakeAlertFromEvent()
    Dim objAlert
    Dim objEvent

    If (ScriptContext.IsEvent()) Then
        Set objEvent = ScriptContext.Event
        Set objAlert = ScriptContext.CreateAlert()

        objAlert.Computer = objEvent.SourceComputer
        objAlert.ComputerDomain = objEvent.SourceDomain
        objAlert.Description = objEvent.EventParameter(1)
    Else
        Set objAlert = Nothing
    End If

    Set objEvent = Nothing

    Set MakeAlertFromEvent = objAlert
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, Event Object


Parameters Property

The Parameters property gets a VarSet object that contains the parameters sent from MOM when the script was invoked.

[VBScript] ScriptContext.Parameters

Access

Read-only

Return Value

Object (VarSet)

Remarks

You can set the parameters in the MOM Administrator console on the Script Properties Parameters tab for the script.

Examples

The following example shows how to access the parameters specified on the Script Properties Parameters tab for the script.

[VBScript]
Function GetParam(strParamName)
    Dim objParameters, vntVariable

    Set objParameters = ScriptContext.Parameters
    vntVariable = objParameters.get(strParamName)

    Set objParameters = Nothing

    GetParam = vntVariable
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object


PerfData Property

The PerfData property gets the PerfData object that caused MOM to invoke the script.

[VBScript] ScriptContext.PerfData

Access

Read/Write

Return Value

Object

Examples

The following example shows how to access the PerfData object that caused MOM to invoke the script.

[VBScript]
Function GetPerfData()
    Dim objPerfData

    If (ScriptContext.IsPerfData()) then
        Set objPerfData = ScriptContext.PerfData
    Else
        Set objPerfData = Nothing
    End If

    Set GetPerfData = objPerfData
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext Object, PerfData Object


ScriptState Object

The ScriptState object represents the script state of MOM. You can use a ScriptState object as a store for script variables during the lifetime of the OnePoint service. When the OnePoint service is stopped, all data stored in the ScriptState object is discarded.

Methods

Name | Description
CreateSet | Creates a new VarSet object.
DeleteSet | Deletes the specified VarSet object.
GetSet | Gets a VarSet object by name.
SaveSet | Saves a VarSet object by name.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptContext.GetScriptState Method


CreateSet Method

The CreateSet method creates a new VarSet object.

[VBScript] ScriptState.CreateSet()

Return Value

Object (VarSet)

Remarks

You can use this VarSet object as a persistent store for script variables. Note that a name is not associated with the VarSet object until it is saved with the ScriptState.SaveSet method.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptState Object, VarSet Object


DeleteSet Method

The DeleteSet method deletes the specified VarSet object.

[VBScript] ScriptState.DeleteSet(VarSetName String)

Parameters

VarSetName
Specifies the VarSet object to delete.

Return Value

None

Examples

The following example shows how to delete the specified VarSet object.

[VBScript]
Function RemoveSavedVarSet(strVarSetName)
    Dim objScriptState

    Set objScriptState = ScriptContext.GetScriptState()
    Call objScriptState.DeleteSet(strVarSetName)

    Set objScriptState = Nothing
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptState Object


GetSet Method

The GetSet method gets a VarSet object specified by name.

[VBScript] ScriptState.GetSet(VarSetName String)

Parameters

VarSetName
Specifies the name of the VarSet object to get.

Return Value

VarSet

Remarks

If the specified VarSet object does not exist, the GetSet method automatically creates and returns a new VarSet object with that name.

Examples

The following example shows how to get the VarSet object using its name.

[VBScript]
Function GetSavedVarSet(strVarSetName)
    Dim objScriptState
    Dim objVarSet

    Set objScriptState = ScriptContext.GetScriptState()
    Set objVarSet = objScriptState.GetSet(strVarSetName)

    Set objScriptState = Nothing

    Set GetSavedVarSet = objVarSet
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptState Object


SaveSet Method

The SaveSet method saves a VarSet object by name.

[VBScript] ScriptState.SaveSet(VarSetName String, VarSet Object)

Parameters

VarSetName
Specifies the name to save the VarSet object as.
VarSet
Specifies the VarSet object to save.

Return Value

None

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ScriptState Object


VarSet Object

The VarSet object stores a group of variables that are globally accessible by all scripts running in MOM. The VarSet object is automatically instantiated by the MOM scripting environment. You can use a VarSet object as a store for global script variables during the lifetime of the OnePoint service. When the OnePoint service is stopped, all data stored in the VarSet object is discarded.

Methods

Name | Description
DumpToFile | Writes the contents of a VarSet object to a file.
get | Retrieves a variable value from a VarSet object.
put | Writes a variable value to a VarSet object.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

State Object


DumpToFile Method

The DumpToFile method writes the contents of a VarSet object to a file.

[VBScript] GetScriptState.GetScriptSet.DumpToFile(FileName String)

Parameters

FileName
Specifies the name or path of the file used to store the VarSet values.

Return Value

None

Remarks

Unless the FileName parameter contains a complete folder path, the file will be created in the MOM OnePoint folder.

Examples

The following example shows how to write the contents of the specified VarSet object to a file in the MOM OnePoint folder.

[VBScript]
Function SaveVarSetToFile(strVarSetName)
    Dim objScriptState
    Dim objVarSet
    Dim strFileName
    Dim dtmNow

    dtmNow = Now()

    strFileName = Month(dtmNow) & "_" & Day(dtmNow) & "_" & _
                  Hour(dtmNow) & "_" & Minute(dtmNow) & "_" & _
                  Second(dtmNow) & ".dat"

    Set objScriptState = ScriptContext.GetScriptState()
    Set objVarSet = objScriptState.GetSet(strVarSetName)
    Call objVarSet.DumpToFile(strFileName)

    Set objScriptState = Nothing
    Set objVarSet = Nothing

    SaveVarSetToFile = strFileName
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

VarSet Object


get Method

The get method gets a variable value from the VarSet object.

[VBScript] VarSet.get(VariableName String)

Parameters

VariableName
Specifies the name of the value to retrieve from the VarSet object.

Return Value

Variant

Examples

The following example shows how to use a VarSet object to store data between script sessions.

[VBScript]
Function IncrementCriticalErrors()
    Const ERROR_VARSET_NAME = "Error Tracker"
    Const NORMAL_ERROR_COUNT = "Number of Errors"
    Const CRITICAL_ERROR_COUNT = "Number of Critical Errors"

    Dim objScriptState
    Dim objErrorVarSet
    Dim vntCriticalErrors

    Set objScriptState = ScriptContext.GetScriptState()
    Set objErrorVarSet = objScriptState.GetSet(ERROR_VARSET_NAME)

    ' get and modify count values
    vntCriticalErrors = objErrorVarSet.get(CRITICAL_ERROR_COUNT)
    vntCriticalErrors = CLng(vntCriticalErrors) + 1

    ' save variable changes back to the VarSet
    Call objErrorVarSet.put(CRITICAL_ERROR_COUNT, vntCriticalErrors)

    ' save the VarSet
    Call objScriptState.SaveSet(ERROR_VARSET_NAME, objErrorVarSet)

    Set objErrorVarSet = Nothing
    Set objScriptState = Nothing

    IncrementCriticalErrors = CLng(vntCriticalErrors)
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

VarSet Object, VarSet.put Method


put Method

The put method saves a variable value in the VarSet object.

[VBScript] VarSet.put(VariableName String, Value Variant)

Parameters

VariableName
Specifies the name of the variable value to save to the VarSet object.
Value
Specifies the variable value to save to the VarSet object.

Return Value

None

Examples

The following example uses the get and put methods to update a value stored in a VarSet object.

[VBScript]
Function IncrementCriticalErrors()
    Const ERROR_VARSET_NAME = "Error Tracker"
    Const NORMAL_ERROR_COUNT = "Number of Errors"
    Const CRITICAL_ERROR_COUNT = "Number of Critical Errors"

    Dim objScriptState
    Dim objErrorVarSet
    Dim vntCriticalErrors

    Set objScriptState = ScriptContext.GetScriptState()
    Set objErrorVarSet = objScriptState.GetSet(ERROR_VARSET_NAME)

    ' get and modify count values
    vntCriticalErrors = objErrorVarSet.get(CRITICAL_ERROR_COUNT)
    vntCriticalErrors = CLng(vntCriticalErrors) + 1

    ' save variable changes back to the VarSet
    Call objErrorVarSet.put(CRITICAL_ERROR_COUNT, vntCriticalErrors)

    ' save the VarSet
    Call objScriptState.SaveSet(ERROR_VARSET_NAME, objErrorVarSet)

    Set objErrorVarSet = Nothing
    Set objScriptState = Nothing

    IncrementCriticalErrors = CLng(vntCriticalErrors)
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

VarSet Object, VarSet.get Method


State Object

The State object is a named instance of the VarSet object that contains values set through a MOM rule with the Update a State Variable response type. As a response to an event, alert, or performance measurement, you can save and edit state information in the State object. You can then access this state information from scripts.

There are different types of state operations. Most state operations edit a variable by incrementing it, decrementing it, or setting it to a specific value. State operations include the following:

  • Increment a variable value
  • Decrement a variable value
  • Set a variable value to property
  • Set a variable value to text
  • Set a variable value to number

These operations make the variable specified in the State variable name field available to scripts through the State object.

The Store the last N occurrences operation creates the following variables with the state variable root:

  • State_Variable_Root.size: Specifies the number of occurrences stored. This value is equal to the value specified in the Number of occurrences field.
  • State_Variable_Root.first: Specifies which State_Variable_Root.N variable contains the earliest occurrence of the variable. If State_Variable_Root.first equals 4, then the earliest occurrence of the variable is stored in State_Variable_Root.4.
  • State_Variable_Root.last: Specifies which State_Variable_Root.N variable contains the latest occurrence of the variable. If State_Variable_Root.last equals 2, then the latest occurrence of the variable is stored in State_Variable_Root.2.
  • State_Variable_Root.N: Specifies each of the occurrences of the variable. N can be 1 to the value specified in the Number of occurrences field. The occurrences cycle through the N variables overwriting the oldest occurrence. Use the .first and .last variables to keep track of the order of occurrences.

Set the operation, values, and name and root fields for state operations with the State Variable Update Operation window.

Examples

The following example shows how to access the number of times an event occurred after setting a state response to increment the LogonViolations.Count state variable name.

[VBScript]
Function GetNumberOfLogonViolations()
    Dim vntCount

    vntCount = State.get("LogonViolations.Count")
    GetNumberOfLogonViolations = CLng(vntCount)
End Function

The following example shows how to access the last occurrence of the logon domain after setting a state response to record the last 50 occurrences of the Logging Domain variable with the LogonViolations.LoggingDomain state variable root.

[VBScript]
Function GetLastDomain()
    Dim vntLastDomain, vntLastOccurrence

    vntLastOccurrence = State.get("LogonViolations.LoggingDomain.last")
    vntLastDomain = State.get("LogonViolations.LoggingDomain." & vntLastOccurrence)
    GetLastDomain = CStr(vntLastDomain)
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

VarSet Object


Using Operating System APIs in Scripts

You can make your MOM scripts less dependent on the helper objects by relying instead on various Windows Management Instrumentation (WMI) and other APIs that are included with Windows. Using built-in APIs provides the following advantages:

  • Scripts continue to call fast, external compiled code libraries.
  • Multiple scripts can continue to reuse an external library for commonly used functions.
  • Scripts are easier to upgrade.
  • Scripts use well-documented, commonly used Windows APIs rather than specialized APIs that are specific to MOM. If you are already familiar with WMI for automating Windows management tasks, you will not need to learn a new set of APIs.
  • In most cases, the WMI and COM classes recommended in this documentation expose far more methods and properties than the MOM helper objects. These other methods and properties can provide additional benefits for your scripts.

The majority of the helper objects have been deprecated and should not be used when creating new scripts.

For more information about equivalent operating system APIs to use in place of the MOM helper objects, see the following topics:

  • Alternatives to the EventLog Object
  • Alternatives to the INet Object
  • Alternatives to the SCManager Object
  • Alternatives to the SystemManager Object
  • Alternatives to the Utility Object

See Also

Windows Management Instrumentation SDK


Alternatives to the EventLog Object

For new scripts, use the following methods and properties of the Win32_NTEventlogFile WMI class to achieve equivalent results.

Deprecated members | Equivalents
EventLog.BackupEventLog | BackupEventlog method of the Win32_NTEventlogFile WMI class
EventLog.ClearEventLog | ClearEventlog method of the Win32_NTEventlogFile WMI class
EventLog.GetNumberOfEventLogRecords | NumberOfRecords property of the Win32_NTEventlogFile WMI class

Examples

[VBScript]
'*********************************************************************
' Routine: Function BackupEventLog
' Purpose: A replacement for the EventLog.BackupEventLog method
' Notes: Additional credentials are required to work with the
'         Security event log.
'**********************************************************************
Function BackupEventLog(strEventLogName, strOutputFolderName, ByRef strSavedFileName, strComputer)
    Dim objEventlogFiles, objEventlogFile
    Dim strBackupLogName
    Dim lngResult
    Dim strQuery

    strBackupLogName =  "OMEventLog_" & strEventLogName & "_" & _
                        Month(Now) & "_" & Day(Now()) & "_" & Hour(Now()) _
                         & "_" & Minute(Now()) & "_" & Second(Now()) & ".evt"

    strSavedFileName = strOutputFolderName & "/" & strBackupLogName

    strQuery = "SELECT * FROM Win32_NTEventLogFile WHERE LogfileName='" & strEventLogName & "'"
    Set objEventlogFiles = GetObject("WinMgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery(strQuery)

    For Each objEventlogFile In objEventlogFiles
       lngResult = objEventlogFile.BackupEventlog(strSavedFileName)
    Next

    Set objEventlogFiles = Nothing
    Set objEventlogFile =  Nothing

    BackupEventLog = lngResult
End Function

[VBScript]
'*********************************************************************
' Routine: Function ClearEventLog
' Purpose: A replacement for the EventLog.ClearEventLog method
' Notes: Additional credentials are required to work with the
'         Security event log.
'**********************************************************************
Function ClearEventLog(strEventLogName, strOutputFolderName, ByRef strSavedFileName, strComputer)
    Dim objEventlogFile, objEventlogFiles
    Dim lngResult
    Dim strQuery

    strQuery = "SELECT * FROM Win32_NTEventLogFile WHERE LogfileName='" & strEventLogName & "'"
    Set objEventlogFiles = GetObject("WinMgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery(strQuery)

    For Each objEventlogFile In objEventlogFiles
        ' BackupEventLog - uses the function in the previous example
       BackupEventLog(strEventLogName, strOutputFolderName, strSavedFileName, strComputer)
       lngResult = objEventlogFile.ClearEventlog()
    Next

    Set objEventlogFiles = Nothing
    Set objEventlogFile =  Nothing

    ClearEventLog = lngResult
End Function

[VBScript]
'*********************************************************************
' Routine: Function GetNumberOfEventLogRecords
' Purpose: A replacement for EventLog.GetNumberOfEventLogRecords
' Notes: Additional credentials are required to work with the
'         Security event log.
'**********************************************************************
Function GetNumberOfEventLogRecords(strEventLogName, ByRef lngNumRecords, strComputer)
    Dim objEventlogFiles, objEventlogFile
    Dim strQuery

    strQuery = "SELECT * FROM Win32_NTEventLogFile WHERE LogfileName='" & strEventLogName & "'"
    Set objEventlogFiles = GetObject("WinMgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery(strQuery)

    For Each objEventlogFile In objEventlogFiles
       lngNumRecords = objEventlogFile.NumberOfRecords
    Next

    Set objEventlogFiles = Nothing
    Set objEventlogFile = Nothing

    GetNumberOfEventLogRecords = lngNumRecords
End Function

For more information about the Win32_NTEventlogFile class, see the Windows Management Instrumentation SDK.


Alternatives to the INet Object

For new scripts, use the following methods and properties of the MSXML object to achieve equivalent results.

Deprecated members | Equivalents
INet.GetFTPFile | Open method, Send method, and the responseText property of the MSXML object
INet.GetHTTPFile | Open method, Send method, and the responseText property of the MSXML object
INet.Ping | Open method and Send method of the MSXML object

Examples

The following example uses the MSXML object to request a document from an FTP server.

[VBScript]
'*********************************************************************
' Routine: Function GetFTPFile
' Purpose: A replacement for the INet.GetFTPFile method
'**********************************************************************
Function GetFTPFile(strURL)
    Dim objXML
    Dim strFTPResponse

    Set objXML = CreateObject("Msxml2.XMLHTTP")

    Call objXML.Open("GET", strURL, False)
    Call objXML.Send()

    strFTPResponse = objXML.responseText

    Set objXML = Nothing

    GetFTPFile = strFTPResponse
End Function

The following example uses the MSXML object to request a document from an HTTP server.

[VBScript]
'*********************************************************************
' Routine: Function GetHTTPFile
' Purpose: A replacement for the INet.GetHTTPFile method
'**********************************************************************
Function GetHTTPFile(strURL)
    Dim objXML
    Dim strHTTPResponse

    Set objXML = CreateObject("Msxml2.XMLHTTP")

    Call objXML.Open("GET", strURL, False)
    Call objXML.Send()

    strHTTPResponse = objXML.responseText

    Set objXML = Nothing

    GetHTTPFile = strHTTPResponse
End Function

The following example checks the availability and performance of an HTTP server using a test request sent by the MSXML object. The example assumes that there is a MOM processing rule configured to monitor the event created by this script.

[JScript]
// Constants
EVENT_TYPE_ERROR = 1;
EVENT_SOURCE = "HTTP Ping - availability";

var objParams = ScriptContext.Parameters;
var strURL = objParams.Get("strURL");

var http = new ActiveXObject("MSXML2.XMLHTTP");
http.open ("GET", strURL, false);
var timebefore = new Date();
http.send();
var timeafter = new Date();
var diff = timeafter - timebefore;
if (http.status != "200")
{
    CreateEvent(5001, EVENT_SOURCE, EVENT_TYPE_ERROR, "", "The server isn't available.");
    // Errors are often returned much faster than a successful request. All requests with
    // error status codes are assigned a higher ping value of 2000 ms.
    diff = 2000;
}

CreatePerformanceData("HTTP Ping", "Time Elapsed", strURL, diff, "");

function CreateEvent(intEventNumber, strEventSource, intEventType, strSourceComputer, strEventMessage)
{
    var objEvent = ScriptContext.CreateEvent();
    objEvent.EventNumber = intEventNumber;
    objEvent.EventSource = strEventSource;
    objEvent.EventType = intEventType;
    if (strSourceComputer != ""){
        objEvent.SourceComputer = strSourceComputer;
        objEvent.LoggingComputer = strSourceComputer;
    }
    objEvent.Message = strEventMessage;
    ScriptContext.Submit(objEvent);
}

function CreatePerformanceData (strObjectName, strCounterName, strInstanceName, dblSampleValue, strSrcComputer)
{
    var objPerfData = ScriptContext.CreatePerfData();

    if (strSrcComputer != "")
    {
        objPerfData.SourceComputer = strSrcComputer;
    }
    objPerfData.ObjectName = strObjectName;
    objPerfData.CounterName = strCounterName;
    objPerfData.InstanceName = strInstanceName;
    objPerfData.Value = dblSampleValue;

    ScriptContext.Submit(objPerfData);
}

For more information about the XMLHTTP object, see the Microsoft XML Core Services SDK.

To save the response text to a file, use the Scripting FileSystemObject object.


Alternatives to the SCManager Object

For new scripts, use the following methods and properties of the Win32_Process WMI class to achieve equivalent results.

Deprecated members | Equivalents
SCManager.ContinueService | ResumeService method of the Win32_Process WMI class
SCManager.GetServiceStatus | Status property of the Win32_Process WMI class
SCManager.PauseService | PauseService method of the Win32_Process WMI class
SCManager.StartService | StartService method of the Win32_Process WMI class
SCManager.StopService | StopService method of the Win32_Process WMI class

For more information about the Win32_Process WMI class, see the Windows Management Instrumentation SDK.


Alternatives to the SystemManager Object

For new scripts, use the following methods and properties of the Win32_ComputerSystem WMI class to achieve equivalent results.

Deprecated members | Equivalents
SystemManager.Domain | Domain property of the Win32_ComputerSystem WMI class
SystemManager.OS | Caption property of the Win32_ComputerSystem WMI class
SystemManager.OSBuildNumber | BuildNumber property of the Win32_ComputerSystem WMI class
SystemManager.OSMajorVersion | Version property of the Win32_ComputerSystem WMI class
SystemManager.OSMinorVersion | Version property of the Win32_ComputerSystem WMI class

Examples

[VBScript]
'*********************************************************************
' Routine: Function Domain
' Purpose: A replacement for the SystemManager.Domain property
'**********************************************************************
Function Domain()
    Dim objComputerSystem
    Dim objNet
    Dim strDomain
    Dim strComputer

    Set objNet = CreateObject("Wscript.Network")
    strComputer = objNet.ComputerName
    Set objNet = Nothing

    Set objComputerSystem = GetObject("WinMgmts:Win32_ComputerSystem.Name=""" & strComputer & """")

    If Not(objComputerSystem Is Nothing) Then
        strDomain = objComputerSystem.Domain
    End If

    Set objComputerSystem = Nothing
    Set objNet = Nothing

    Domain = strDomain
End Function

[VBScript]
'*********************************************************************
' Routine: Function OS
' Purpose: A replacement for the SystemManager.OS property
'**********************************************************************
Function OS()
    Dim objOperatingSystem
    Dim strCaption
    Dim strObjectName

    ' Note: the partition information in the Name property will likely
    '       differ from computer to computer.
    strObjectName = "Microsoft Windows 2000 Server|C:\\WINNT|\\Device\\Harddisk0\\Partition2"

    Set objOperatingSystem = GetObject("WinMgmts:Win32_OperatingSystem.Name=""" & strObjectName & """")

    If Not(objOperatingSystem Is Nothing) Then
        strCaption = objOperatingSystem.Caption
    End If

    Set objOperatingSystem = Nothing

    OS = strCaption
End Function

[VBScript]
'*********************************************************************
' Routine: Function OSBuildNumber
' Purpose: A replacement for the SystemManager.OSBuildNumber property
'**********************************************************************
Function OSBuildNumber()
    Dim objOperatingSystem
    Dim strBuildNumber
    Dim strObjectName

    strObjectName = "Microsoft Windows 2000 Server|C:\\WINNT|\\Device\\Harddisk0\\Partition2"

    Set objOperatingSystem = GetObject("WinMgmts:Win32_OperatingSystem.Name=""" & strObjectName & """")

    If Not(objOperatingSystem Is Nothing) Then
        strBuildNumber = objOperatingSystem.BuildNumber
    End If

    Set objOperatingSystem = Nothing

    OSBuildNumber = strBuildNumber
End Function

[VBScript]
'*********************************************************************
' Routine: Function OSMajorVersion
' Purpose: A replacement for the SystemManager.OSMajorVersion property
'**********************************************************************
Function OSMajorVersion()
    Dim objOperatingSystem
    Dim strFullVersion
    Dim strMajorVersion
    Dim strObjectName
    Dim lngFirstSeparatorPos

    strObjectName = "Microsoft Windows 2000 Server|C:\\WINNT|\\Device\\Harddisk0\\Partition2"

    Set objOperatingSystem = GetObject("WinMgmts:Win32_OperatingSystem.Name=""" & strObjectName & """")

    If Not(objOperatingSystem Is Nothing) Then
        strFullVersion = objOperatingSystem.Version
        lngFirstSeparatorPos = InStr(strFullVersion, ".")
        strMajorVersion = Left(strFullVersion, lngFirstSeparatorPos - 1)
    End If

    Set objOperatingSystem = Nothing

    OSMajorVersion = strMajorVersion
End Function

[VBScript]
'*********************************************************************
' Routine: Function OSMinorVersion
' Purpose: A replacement for the SystemManager.OSMinorVersion property
'**********************************************************************
Function OSMinorVersion()
    Dim objOperatingSystem
    Dim strFullVersion
    Dim strMinorVersion
    Dim strObjectName
    Dim lngFirstSeparatorPos

    strObjectName = "Microsoft Windows 2000 Server|C:\\WINNT|\\Device\\Harddisk0\\Partition2"

    Set objOperatingSystem = GetObject("WinMgmts:Win32_OperatingSystem.Name=""" & strObjectName & """")

    If Not(objOperatingSystem Is Nothing) Then
        strFullVersion = objOperatingSystem.Version
        lngFirstSeparatorPos = InStr(strFullVersion, ".")
        strMinorVersion = Mid(strFullVersion, lngFirstSeparatorPos + 1, 1)
    End If

    Set objOperatingSystem = Nothing

    OSMinorVersion = strMinorVersion
End Function

For more information about the Win32_ComputerSystem WMI class, see the Windows Management Instrumentation SDK.


Alternatives to the Utility Object

For new scripts, use the following to achieve equivalent results.

Deprecated members | Equivalents
Utility.CreateProcess | Create method of the Win32_Process WMI class
Utility.LogEvent | LogEvent method of the WScript.Shell object

Examples

[VBScript]
'*********************************************************************
' Routine: Function CreateProcess
' Purpose: A replacement for the Utility.CreateProcess method
'**********************************************************************
Function CreateProcess(strEXEPath, strCommandLine, ByRef vntExitCode)
    Dim objProcess
    Dim lngProcessID

    Set objProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_Process")

    If Not(IsNull(strCommandLine)) Then
        vntExitCode = objProcess.Create(strCommandLine, Null, lngProcessID)
    Else
        vntExitCode = objProcess.Create(strEXEPath, Null, lngProcessID)
    End If

    Set objProcess = Nothing

    CreateProcess = vntExitCode
End Function

[VBScript]
Const SUCCESS = 0
Const ERROR = 1
Const WARNING = 2
Const INFORMATION = 4
Const AUDIT_SUCCESS = 8
Const AUDIT_FAILURE = 16

'*********************************************************************
' Routine: Function LogEvent
' Purpose: A replacement for the Utility.LogEvent method
'**********************************************************************
Function LogEvent(strComputer, strDescription, lngSeverity)
    Dim objShell
    Dim blnSuccess

    ' create instance
    Set objShell = CreateObject("WScript.Shell")

    blnSuccess = objShell.LogEvent(lngSeverity, strDescription, strComputer)

    Set objShell = Nothing

    LogEvent = blnSuccess
End Function

For more information about the Win32_Process WMI class, see the Windows Management Instrumentation SDK. For more information about the WScript.Shell object, see the documentation available at the Windows Script site.


ActiveDirectory Object

The MOM ActiveDirectory object is used to monitor the Active Directory service.

Methods

Name | Description
BindDomainNamingMaster | Binds to the domain-naming master to determine the amount of time required for binding.
BindInfrastructureMaster | Binds to the infrastructure master to determine the amount of time required for binding.
BindLostFoundContainer | Binds to the lost and found container to determine the amount of time required for binding.
BindObject | Binds to the specified ActiveDirectory object.
BindPDCMaster | Binds to the primary domain controller (PDC) master to determine the amount of time required for binding.
BindRIDMaster | Binds to the relative identifier (RID) master to determine the amount of time required for binding.
BindSchemaMaster | Binds to the schema master to determine the amount of time required for binding.
GetDatabaseInfo | Retrieves the path and size of the Active Directory database. It also returns the amount of free space, in kilobytes, for the drive on which the database is located.
GetLogFileInfo | Retrieves the path and size of the active log files. It also returns the amount of free space, in kilobytes, for the drive on which the log files are located.
NextDomainController | Gets the next domain controller in the list of domain controllers in the forest.
NextGlobalCatalog | Gets the next global catalog in the forest.
NextReplicationPartner | Gets the next replication partner for the domain controller.
RefreshDomainControllers | Resets the list of domain controllers in the forest.
RefreshGlobalCatalogs | Resets the list of global catalogs in the forest.
RefreshReplicationPartners | Resets the list of replication partners for the domain controller.
SearchGlobalCatalog | Performs the global catalog query specified by the Query parameter and returns the number of objects that match the query.

Properties

Name | Description
BindCount | Gets a running count of the bind operations performed.
BindLast | Gets the time, in milliseconds, of the last Active Directory bind operation performed.
BindTotal | Gets a running total of the bind times performed.
Domain | Gets or sets the domain to indicate where Active Directory bind operations are to occur.
DomainNamingMaster | Gets the Domain Name System (DNS) formatted name of the domain-naming master.
DomainNamingMasterBind | Gets the time required to bind to the domain-naming master using the BindDomainNamingMaster method.
GlobalCatalogSearchTime | Gets the time, in milliseconds, of the last global catalog search.
InfrastructureMaster | Gets the DNS-formatted name of the infrastructure master.
InfrastructureMasterBind | Gets the time required to bind to the infrastructure master using the BindInfrastructureMaster method.
LastError | Gets the last error encountered by the object.
LostAndFoundCount | Gets the number of Active Directory objects in the lost and found container. To determine the lost and found count, you must first bind to the lost and found container.
PDCMaster | Gets the DNS-formatted name of the PDC master.
PDCMasterBind | Gets the time required to bind to the PDC master using the BindPDCMaster method.
Password | Gets the password to be used by the object for authentication.
RIDMaster | Gets the DNS-formatted name of the RID master.
RIDMasterBind | Gets the time required to bind to the RID master using the BindRIDMaster method.
SchemaMaster | Gets the DNS-formatted name of the schema master.
SchemaMasterBind | Gets the time required to bind to the schema master using the BindSchemaMaster method.
Server | Gets or sets the domain controller where Active Directory bind operations are to occur.
UserName | Gets or sets the user name to be used by the object for authentication.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


BindDomainNamingMaster Method

The BindDomainNamingMaster method binds to the domain-naming master to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindDomainNamingMaster()

Parameters

None

Return Value

Long

Remarks

To get the domain-naming master object, use the BindObject method.

Examples

The following example shows how to get the time required to bind to the domain naming master.

[VBScript]
Function GetTimeToBindToDNMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindDomainNamingMaster()) Then
        lngBindTime = objActiveDirectory.DomainNamingMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToDNMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


BindInfrastructureMaster Method

The BindInfrastructureMaster method binds to the infrastructure master to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindInfrastructureMaster()

Parameters

None

Return Value

Long

Remarks

To get the infrastructure master object, use the BindObject method.

Examples

The following example shows how to get the time required to bind to the infrastructure master.

[VBScript]
Function GetTimeToBindToInfraMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindInfrastructureMaster()) Then
        lngBindTime = objActiveDirectory.InfrastructureMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToInfraMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


BindLostFoundContainer Method

The BindLostFoundContainer method binds to the lost and found container to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindLostFoundContainer()

Parameters

None

Return Value

Long

Remarks

To get the lost and found container object, use the BindObject method.

Examples

The following example binds to the lost and found container and determines the number of objects in the container.

[VBScript]
Function GetLostItemsCount()
    Dim objActiveDirectory
    Dim lngCount

    lngCount = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindLostFoundContainer()) Then
        lngCount = objActiveDirectory.LostAndFoundCount
    End If

    Set objActiveDirectory = Nothing

    GetLostItemsCount = lngCount
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


BindObject Method

The BindObject method binds to the specified ActiveDirectory object.

[VBScript] ActiveDirectory.BindObject(ADsPath String)

Parameters

ADsPath
Specifies the ADs path of the object to bind to in the form of a Lightweight Directory Access Protocol (LDAP) query.

Return Value

Object

Remarks

The BindCount, BindLast, and BindTotal properties are updated when this method is called.

Examples

The following example binds to the rootDSE object of the domain.

[VBScript]
Function GetRootDSE()
    Dim objActiveDirectory, objRootDSE

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")
    Set objRootDSE = objActiveDirectory.BindObject("LDAP://rootDSE")

    Set objActiveDirectory = Nothing

    Set GetRootDSE = objRootDSE
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


BindPDCMaster Method

The BindPDCMaster method binds to the primary domain controller (PDC) master to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindPDCMaster()

Parameters

None

Return Value

Long

Remarks

To get the PDC object, use the BindObject method.

Examples

The following example shows how to get the time required to bind to the PDC master.

[VBScript]
Function GetTimeToBindToPDCMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindPDCMaster()) Then
        lngBindTime = objActiveDirectory.PDCMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToPDCMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


BindRIDMaster Method

The BindRIDMaster method binds to the relative identifier (RID) master to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindRIDMaster()

Parameters

None

Return Value

Long

Remarks

To get the RID master object, use the BindObject method.

Examples

The following example shows how to get the time required to bind to the RID master.

[VBScript]
Function GetTimeToBindToRIDMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindRIDMaster()) Then
        lngBindTime = objActiveDirectory.RIDMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToRIDMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


BindSchemaMaster Method

The BindSchemaMaster method binds to the schema master to determine the amount of time required for binding.

[VBScript] ActiveDirectory.BindSchemaMaster()

Parameters

None

Return Value

Long

Remarks

To get the schema master object, use the BindObject method.

Examples

The following example shows how to get the time required to bind to the schema master.

[VBScript]
Function GetTimeToBindToSchemaMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindSchemaMaster()) Then
        lngBindTime = objActiveDirectory.SchemaMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToSchemaMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindObject Method


GetDatabaseInfo Method

The GetDatabaseInfo method retrieves the path and size of the Active Directory database. It also returns the amount of free space, in kilobytes, for the drive on which the database is located.

[VBScript] ActiveDirectory.GetDatabaseInfo(Path Variant, Size Variant, FreeSpace Variant)

Parameters

Path
[Out] Path of the Active Directory database.
Size
[Out] Size, in kilobytes, of the Active Directory database.
FreeSpace
[Out] Amount of free space, in kilobytes, on the drive on which the database is located.

Return Value

Long

Examples

The following example shows how to get information about the Active Directory database.

[VBScript]
Function GetADFreeSpace()
    Dim objActiveDirectory
    Dim strPath
    Dim lngSize, lngFreeSpace

    lngFreeSpace = -1
    lngSize = -1
    strPath = ""

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.GetDatabaseInfo(strPath, lngSize, lngFreeSpace)

    Set objActiveDirectory = Nothing

    GetADFreeSpace = lngFreeSpace
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


GetLogFileInfo Method

The GetLogFileInfo method retrieves the path and size of the active log files. It also returns the amount of free space, in kilobytes, for the drive on which the log files are located.

[VBScript] ActiveDirectory.GetLogFileInfo(Path Variant, Size Variant, FreeSpace Variant)

Parameters

Path
[Out] Path of the Active Directory log files.
Size
[Out] Size, in kilobytes, of the Active Directory log files.
FreeSpace
[Out] Amount of free space, in kilobytes, on the drive on which the log files are located.

Return Value

Long

Examples

The following example shows how to get information about the Active Directory log files.

[VBScript]
Function GetADLogSize()
    Dim objActiveDirectory
    Dim strPath
    Dim lngSize, lngFreeSpace

    strPath = ""
    lngSize = -1
    lngFreeSpace = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.LogFileInfo(strPath, lngSize, lngFreeSpace)

    Set objActiveDirectory = Nothing

    GetADLogSize = lngSize
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


NextDomainController Method

The NextDomainController method gets the next domain controller in the list of domain controllers in the forest.

[VBScript] ActiveDirectory.NextDomainController()

Parameters

None

Return Value

String

Examples

The following example shows how to enumerate the domain controllers in the forest and return their names in an array.

[VBScript]
Function GetDCs()
    Dim objActiveDirectory
    Dim strDomainController
    Dim arrDCs()
    Dim intIndex

    intIndex = 0

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.RefreshDomainControllers()) Then
        strDomainController = objActiveDirectory.NextDomainController()
        While NOT(strDomainController = "")
            ReDim Preserve arrDCs(intIndex)
            arrDCs(intIndex) = strDomainController
            intIndex = intIndex + 1
            strDomainController = objActiveDirectory.NextDomainController()
        Wend
    End If

    Set objActiveDirectory = Nothing

    GetDCs = arrDCs
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


NextGlobalCatalog Method

The NextGlobalCatalog method gets the next global catalog in the forest.

[VBScript] ActiveDirectory.NextGlobalCatalog()

Parameters

None

Return Value

String

Examples

The following example shows how to enumerate the global catalogs in the forest.

[VBScript]
Function GetCatalogs()
    Dim objActiveDirectory
    Dim strGlobalCatalog
    Dim intIndex
    Dim arrCatalogs()

    intIndex = 0

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.RefreshGlobalCatalogs()) Then
        strGlobalCatalog = objActiveDirectory.NextGlobalCatalog()
        While NOT(strGlobalCatalog = "")
            ReDim Preserve arrCatalogs(intIndex)
            arrCatalogs(intIndex) = strGlobalCatalog
            intIndex = intIndex + 1
            strGlobalCatalog = objActiveDirectory.NextGlobalCatalog()
        Wend
    End If

    Set objActiveDirectory = Nothing

    GetCatalogs = arrCatalogs
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


NextReplicationPartner Method

The NextReplicationPartner method gets the next replication partner for the domain controller.

[VBScript] ActiveDirectory.NextReplicationPartner()

Parameters

None

Return Value

String

Examples

The following example shows how to enumerate the replication partners for a domain controller.

[VBScript]
Function GetPartners()
    Dim objActiveDirectory
    Dim strReplicationPartner
    Dim intIndex
    Dim arrPartners()

    intIndex = 0

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.RefreshReplicationPartners()) Then
        strReplicationPartner = objActiveDirectory.NextReplicationPartner()
        While NOT(strReplicationPartner = "")
            ReDim Preserve arrPartners(intIndex)
            arrPartners(intIndex) = strReplicationPartner
            intIndex = intIndex + 1
            strReplicationPartner = objActiveDirectory.NextReplicationPartner()
        Wend
    End If

    Set objActiveDirectory = Nothing

    GetPartners = arrPartners
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


RefreshDomainControllers Method

The RefreshDomainControllers method resets the list of domain controllers in the forest.

[VBScript] ActiveDirectory.RefreshDomainControllers()

Parameters

None

Return Value

Long

Examples

The following example shows how to enumerate the domain controllers in the forest.

[VBScript]
Dim objActiveDirectory
Dim strDomainController

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.RefreshDomainControllers()) Then
    strDomainController = objActiveDirectory.NextDomainController()
    While NOT(strDomainController = "")
        strDomainController = objActiveDirectory.NextDomainController()
    Wend
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


RefreshGlobalCatalogs Method

The RefreshGlobalCatalogs method resets the list of global catalogs in the forest.

[VBScript] ActiveDirectory.RefreshGlobalCatalogs()

Parameters

None

Return Value

Long

Examples

The following example shows how to enumerate the global catalogs in the forest.

[VBScript]
Dim objActiveDirectory
Dim strGlobalCatalog

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.RefreshGlobalCatalogs()) Then
    strGlobalCatalog = objActiveDirectory.NextGlobalCatalog()
    While NOT(strGlobalCatalog = "")
        strGlobalCatalog = objActiveDirectory.NextGlobalCatalog()
    Wend
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


RefreshReplicationPartners Method

The RefreshReplicationPartners method resets the list of replication partners for the domain controller.

[VBScript] ActiveDirectory.RefreshReplicationPartners()

Parameters

None

Return Value

Long

Examples

The following example shows how to enumerate the replication partners for a domain controller.

[VBScript]
Dim objActiveDirectory
Dim strReplicationPartner

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.RefreshReplicationPartners()) Then
    strReplicationPartner = objActiveDirectory.NextReplicationPartner()
    While NOT(strReplicationPartner = "")
        strReplicationPartner = objActiveDirectory.NextReplicationPartner()
    Wend
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


SearchGlobalCatalog Method

The SearchGlobalCatalog method performs the global catalog query specified by the Query parameter and returns the number of objects that match the query.

[VBScript] ActiveDirectory.SearchGlobalCatalog(Query String)

Parameters

Query
Specifies the query to perform in the form of an LDAP query.

Return Value

Long. Returns -1 if an error occurred.

Remarks

If an error occurs, information is returned using the built-in, error-handling mechanism provided by the scripting language.

Examples

The following example shows how to determine the time required to search the global catalog.

[VBScript]
Dim objActiveDirectory
Dim lngObjectCount, lngSearchTimeSet

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

lngObjectCount = objActiveDirectory.SearchGlobalCatalog("(objectCategory=person)")

If (lngObjectCount >= 0) Then
    lngSearchTime = objActiveDirectory.GlobalCatalogSearchTime
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


BindCount Property

The BindCount property gets a running count of the bind operations performed.

[VBScript] ActiveDirectory.BindCount

Access

Read-only

Return Value

Long

Examples

The following example performs a bind operation and determines the average bind time to Active Directory.

[VBScript]
Function GetAverageTimeToBindToPDC(strDomain)
    Dim objActiveDirectory
    Dim lngBindTotal, lngBindCount, fAverageBindTime

    fAverageBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.Domain = strDomain

    If (objActiveDirectory.BindPDCMaster()) Then
        lngBindTotal = objActiveDirectory.BindTotal
        lngBindCount = objActiveDirectory.BindCount

        If (lngBindCount > 0) Then
            fAverageBindTime = lngBindTotal / lngBindCount
        End If
    End If

    Set objActiveDirectory = Nothing

    GetAverageTimeToBindToPDC = fAverageBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


BindLast Property

The BindLast property gets the time, in milliseconds, of the last Active Directory bind operation performed.

[VBScript] ActiveDirectory.BindLast

Access

Read-only

Return Value

Long

Examples

The following example shows how to determine the time required to bind to the rootDSE object.

[VBScript]
Function GetBindTime()
    Dim objActiveDirectory
    Dim objRootDSE
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.BindObject("LDAP://rootDSE", objRootDSE)
    lngBindTime = objActiveDirectory.BindLast

    Set objRootDSE = Nothing
    Set objActiveDirectory = Nothing

    GetBindTime = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


BindTotal Property

The BindTotal property gets a running total of the bind times performed.

[VBScript] ActiveDirectory.BindTotal

Access

Read-only

Return Value

Long

Examples

The following example shows how to determine the total time for the bind operations performed.

[VBScript]
Function GetAverageTimeToBindToPDC(strDomain)
    Dim objActiveDirectory
    Dim lngBindTotal, lngBindCount, fAverageBindTime

    fAverageBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.Domain = strDomain

    If (objActiveDirectory.BindPDCMaster()) Then
        lngBindTotal = objActiveDirectory.BindTotal
        lngBindCount = objActiveDirectory.BindCount

        If (lngBindCount > 0) Then
            fAverageBindTime = lngBindTotal / lngBindCount
        End If
    End If

    Set objActiveDirectory = Nothing

    GetAverageTimeToBindToPDC = fAverageBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


Domain Property (Active Directory)

The Domain property gets or sets the domain to indicate where Active Directory bind operations are to occur.

[VBScript] ActiveDirectory.Domain

Access

Read/Write

Return Value

String

Remarks

You can set either the Server property or the Domain property, but you should not set both. If both properties are assigned values, the Server property takes precedence.

Examples

The following example performs a bind operation and determines the average bind time to Active Directory.

[VBScript]
Function GetAverageTimeToBindToPDC(strDomain)
    Dim objActiveDirectory
    Dim lngBindTotal, lngBindCount, fAverageBindTime

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    objActiveDirectory.Domain = strDomain

    If (objActiveDirectory.BindPDCMaster()) Then
        lngBindTotal = objActiveDirectory.BindTotal
        lngBindCount = objActiveDirectory.BindCount

        If (lngBindCount > 0) Then
            fAverageBindTime = lngBindTotal / lngBindCount
        End If
    End If

    Set objActiveDirectory = Nothing

    GetAverageTimeToBindToPDC = fAverageBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.Server Property


DomainNamingMaster Property

The DomainNamingMaster property gets the Domain Name System (DNS) formatted name of the domain naming master.

[VBScript] ActiveDirectory.DomainNamingMaster

Access

Read-only

Return Value

String

Examples

The following example shows how to get the DNS-formatted name of the domain naming master.

[VBScript]
Function GetDomainMasterName()
    Dim objActiveDirectory
    Dim strName

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    strName = objActiveDirectory.DomainNamingMaster

    Set objActiveDirectory = Nothing

    GetDomainMasterName = strName
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


DomainNamingMasterBind Property

The DomainNamingMasterBind property gets the time required to bind to the domain-naming master using the BindDomainNamingMaster method.

[VBScript] ActiveDirectory.DomainNamingMasterBind

Access

Read-only

Return Value

Long

Examples

The following example shows how to get the time required to bind to the domain naming master.

[VBScript]
Function GetTimeToBindToDNMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindDomainNamingMaster()) Then
        lngBindTime = objActiveDirectory.DomainNamingMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToDNMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindDomainNamingMaster Method


GlobalCatalogSearchTime Property

The GlobalCatalogSearchTime property gets the time, in milliseconds, of the last global catalog search.

[VBScript] ActiveDirectory.GlobalCatalogSearchTime

Access

Read-only

Return Value

Long

Examples

The following example shows how to determine the time required to search the global catalog.

[VBScript]
Function GetCatalogSearchTime()
    Dim objActiveDirectory
    Dim lngObjectCount, lngSearchTime

    lngSearchTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    lngObjectCount = objActiveDirectory.SearchGlobalCatalog("(objectCategory=person)")
    If (lngObjectCount >= 0) Then
        lngSearchTime = objActiveDirectory.GlobalCatalogSearchTime
    End If

    Set objActiveDirectory = Nothing

    GetCatalogSearchTime = lngSearchTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


InfrastructureMaster Property

The InfrastructureMaster property gets the DNS formatted name of the infrastructure master.

[VBScript] ActiveDirectory.InfrastructureMaster

Parameters

None

Access

Read-only

Return Value

String

Examples

The following example shows how to get the DNS-formatted name of the infrastructure master.

[VBScript]
Function GetInfraMasterName()
    Dim objActiveDirectory
    Dim strName

    strName = ""

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    strName = objActiveDirectory.InfrastructureMaster

    Set objActiveDirectory = Nothing

    GetInfraMasterName = strName
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


InfrastructureMasterBind Property

The InfrastructureMasterBind property gets the time required to bind to the infrastructure master using the BindInfrastructureMaster method.

[VBScript] ActiveDirectory.InfrastructureMasterBind

Access

Read-only

Return Value

Long

Examples

The following example shows how to get the time required to bind to the infrastructure master.

[VBScript]
Function GetTimeToBindToInfraMaster()
    Dim objActiveDirectory
    Dim lngBindTime

    lngBindTime = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindInfrastructureMaster()) Then
        lngBindTime = objActiveDirectory.InfrastructureMasterBind
    End If

    Set objActiveDirectory = Nothing

    GetTimeToBindToInfraMaster = lngBindTime
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindInfrastructureMaster Method


LastError Property

The LastError property gets the last error encountered by the object.

[VBScript] ActiveDirectory.LastError

Access

Read-only

Return Value

String

Remarks

Beginning in MOM SP1, you should use the error handling provided by the programming language instead of the LastError property.

Examples

The following example shows how to retrieve an error from the last operation.

[VBScript]
Function GetADErrorDescription()
    Dim objActiveDirectory
    Dim strError

    strError = ""

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If Not(objActiveDirectory.BindPDCMaster()) Then
        strError = objActiveDirectory.LastError
    End If

    Set objActiveDirectory = Nothing

    GetADErrorDescription = strError
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


LostAndFoundCount Property

The LostAndFoundCount property gets the number of Active Directory objects in the lost and found container. To determine the lost and found count, you must first bind to the lost and found container using the BindLostFoundContainer method.

[VBScript] ActiveDirectory.LostAndFoundCount

Access

Read-only

Return Value

Long

Remarks

To bind to the lost and found container without updating the LostAndFoundCount property, use the BindObject method instead of the BindLostFoundContainer method.

Examples

The following example shows how to determine the number of objects in the lost and found container.

[VBScript]
Function GetLostItemsCount()
    Dim objActiveDirectory
    Dim lngCount

    lngCount = -1

    Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

    If (objActiveDirectory.BindLostFoundContainer()) Then
        lngCount = objActiveDirectory.LostAndFoundCount
    End If

    Set objActiveDirectory = Nothing

    GetLostItemsCount = lngCount
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindLostFoundContainer Method, ActiveDirectory.BindObject Method


PDCMaster Property

The PDCMaster property gets the DNS-formatted name of the PDC master.

[VBScript] ActiveDirectory.PDCMaster

Access

Read-only

Return Value

String

Examples

The following example shows how to get the DNS-formatted name of the PDC master.

[VBScript]
Dim objActiveDirectory
Dim strMaster

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

strMaster = objActiveDirectory.PDCMaster

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


PDCMasterBind Property

The PDCMasterBind property gets the time required to bind to the PDC master using the BindPDCMaster method.

[VBScript] ActiveDirectory.PDCMasterBind

Access

Read-only

Return Value

Long

Examples

The following example shows how to get the time required to bind to the PDC master.

[VBScript]
Dim objActiveDirectory
Dim lngBindTime

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.BindPDCMaster()) Then
    lngBindTime = objActiveDirectory.PDCMasterBind
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindPDCMaster Method


Password Property

The Password property gets the password to be used by the object for authentication.

[VBScript] ActiveDirectory.Password

Access

Read-only

Return Value

String

Examples

The following example shows how to specify a user to bind to a rootDSE object of a domain.

[VBScript]
Dim objActiveDirectory, objRootDSE
Dim lngBindTime

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

objActiveDirectory.UserName = "someone"
objActiveDirectory.Password = "adiscool"
Set objRootDSE = objActiveDirectory.BindObject("LDAP://rootDSE")
lngBindTime = objActiveDirectory.BindLast

Set objRootDSE = Nothing
Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


RIDMaster Property

The RIDMaster property gets the DNS-formatted name of the RID master.

[VBScript] ActiveDirectory.RIDMaster

Access

Read-only

Return Value

String

Examples

The following example shows how to get the DNS-formatted name of the RID master.

[VBScript]
Dim objActiveDirectory
Dim strMaster

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

strMaster = objActiveDirectory.RIDMaster

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


RIDMasterBind Property

The RIDMasterBind property gets the time required to bind to the RID master using the BindRIDMaster method.

[VBScript] ActiveDirectory.RIDMasterBind

Access

Read-only

Return Value

Long

Examples

The following example shows how to get the time required to bind to the RID master.

[VBScript]
Dim objActiveDirectory
Dim lngBindTimeSet

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.BindRIDMaster()) Then
    lngBindTime = objActiveDirectory.RIDMasterBind
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindRIDMaster Method


SchemaMaster Property

The SchemaMaster property gets the DNS-formatted name of the schema master.

[VBScript] ActiveDirectory.SchemaMaster

Access

Read-only

Return Value

String

Examples

The following example shows how to get the DNS-formatted name of the schema master.

[VBScript]
Dim objActiveDirectory
Dim strMaster

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

strMaster = objActiveDirectory.SchemaMaster

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


SchemaMasterBind Property

The SchemaMasterBind property gets the time required to bind to the schema master using the BindSchemaMaster method.

[VBScript] ActiveDirectory.SchemaMasterBind

Access

Read-only

Return Value

Long

Examples

The following example shows how to get the time required to bind to the schema master.

[VBScript]
Dim objActiveDirectory
Dim lngBindTimeSet

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

If (objActiveDirectory.BindSchemaMaster()) Then
    lngBindTime = objActiveDirectory.SchemaMasterBind
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.BindSchemaMaster Method


Server Property

The Server property gets or sets the domain controller where Active Directory bind operations are to occur.

[VBScript] ActiveDirectory.Server

Access

Read/Write

Return Value

String

Remarks

You can set either the Server property or the Domain property, but you should not set both. If both properties are assigned values, the Server property takes precedence.

Examples

The following example shows how to determine the bind time to the PDC master of a specific domain controller.

[VBScript]
Dim objActiveDirectory
Dim lngBindTime

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

objActiveDirectory.Server = "Server1"
If (objActiveDirectory.BindPDCMaster()) Then
    lngBindTime = objActiveDirectory.PDCMasterBind
End If

Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object, ActiveDirectory.Domain Property


UserName Property (Active Directory)

The UserName property gets or sets the user name to be used by the object for authentication.

[VBScript] ActiveDirectory.UserName

Access

Read/Write

Return Value

String

Examples

The following example shows how to specify a user to bind to a rootDSE object of a domain.

[VBScript]
Dim objActiveDirectory, objRootDSE
Dim lngBindTime

Set objActiveDirectory = CreateObject("McActiveDir.ActiveDirectory")

objActiveDirectory.UserName = "someone"
objActiveDirectory.Password = "adiscool"
Set objRootDSE = objActiveDirectory.BindObject("LDAP://rootDSE")
lngBindTime = objActiveDirectory.BindLast

Set objRootDSE = Nothing
Set objActiveDirectory = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

ActiveDirectory Object


EventLog Object (Deprecated)

The EventLog object reads the Windows NT event log information. This object has been deprecated and should not be used when creating new scripts. It is included only to support existing scripts. For new scripts, see Using Operating System APIs in Scripts.

Methods

Name | Description
BackupEventLog | Saves the specified event log to a backup file. This does not clear the event log.
ClearEventLog | Clears the specified event log and optionally saves the current copy of the log file to a backup file.
GetError | Gets the most recent error description for this object.
GetNumberOfEventLogRecords | Gets the number of records in the specified event log.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


BackupEventLog Method

The BackupEventLog method saves the specified event log to a backup file. This does not clear the event log.

[VBScript] EventLog.BackupEventLog(EventLogName Variant, OutputFolderName Variant, SavedFilePath Variant, [MachineName Variant])

Parameters

EventLogName
Specifies the name of the log file to back up, such as Application or System.
OutputFolderName
Specifies the folder to which the output file should be saved. When backing up event logs from the local computer, this parameter can be a string containing system environment variables (such as %TEMP%). On remote computers where the system environment may vary, set this parameter to a specific folder name or to an empty string.
SavedFilePath
Set to the path name of the file to which the event log was saved. The file name is always generated automatically.
MachineName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The backup file name is automatically generated. The format of the file name is OMEventLog_(EventLogName)_(CurrentDate and Time).evt.

The EventLog object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

EventLog Object


ClearEventLog Method

The ClearEventLog method clears the specified event log and optionally saves the current copy of the log file to a backup file.

[VBScript] EventLog.ClearEventLog(EventLogName Variant, OutputFolderName Variant, SavedFileName Variant, [MachineName Variant])

Parameters

EventLogName
Specifies the name of the log file to back up, such as Application or System.
OutputFolderName
Specifies the folder to which the output file should be saved. When backing up event logs from the local computer, this parameter can be a string containing system environment variables (such as %TEMP%). On remote computers where the system environment may vary, set this parameter to a specific folder name or to an empty string.
SavedFileName
Set to the path name of the file to which the event log was saved. The file name is always generated automatically.
MachineName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The backup file name is automatically generated. The format of the file name is OMEventLog_(EventLogName)_(CurrentDate and Time).evt.

This function fails if the event log is empty or a file already exists with the same name as the backup file.

The EventLog object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

EventLog Object


GetError Method (Event Log)

The GetError method gets the most recent error description for this object.

[VBScript] EventLog.GetError()

Parameters

None

Return Value

String

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

EventLog Object


GetNumberOfEventLogRecords Method

The GetNumberOfEventLogRecords method gets the number of records in the specified event log.

[VBScript] EventLog.GetNumberOfEventLogRecords(EventLogName Variant, NumRecords Variant, [MachineName Variant])

Parameters

EventLogName
Specifies the name of the log file from which to retrieve the number of records.
NumRecords
Number of records in the specified event log.
MachineName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The EventLog object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

EventLog Object


INet Object (Deprecated)

The INet object sends HTTP and FTP requests for testing the availability and performance of Internet servers. This object has been deprecated and should not be used when creating new scripts. It is included only to support existing scripts. For new scripts, see Using Operating System APIs in Scripts.

Methods

Name | Description
GetError | Gets the most recent error description for this object.
GetFTPFile | Retrieves a file from an FTP server and saves it to the local hard disk.
GetHTTPFile | Retrieves the URL at the specified location.
Ping | Pings the specified host and measures the response time.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


GetError Method (INet)

The GetError method gets the most recent error description for the INet object.

[VBScript] INet.GetError()

Parameters

None

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Dim objINet
Dim strErrorMsg

Set objINet = CreateObject("OpScrUtil.INet")

If Not(objINet.GetHTTPFile("http://localhost")) Then
    strErrorMsg = "HTTP request failed. The error is " & objINet.GetError()
End If

Set objINet = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

INet Object


GetFTPFile Method

The GetFTPFile method retrieves a file from an FTP server and saves it to the local hard disk.

[VBScript] INet.GetFTPFile(Host Variant, RemoteFile Variant, DestinationLocalFile Variant, [AsciiText Variant], [PortNumber Variant], [LogonUserID Variant], [LogonPassword Variant], [AccessType Variant])

Parameters

Host
Name of the FTP server, such as ftp.microsoft.com.
RemoteFile
Path and name of the file to be retrieved from the FTP server.
DestinationLocalFile
Full path of the local file where the retrieved FTP file will be saved.
AsciiText
[True/False] Determines if the file should be transferred in ASCII or binary mode. This parameter is optional. The default value is False.
PortNumber
Allows specification of a port number other than the default FTP protocol port (21). This parameter is optional.
LogonUserID
User ID used while logging on to the FTP server. This parameter is optional. Leave this parameter blank to specify anonymous logon.
LogonPassword
Password used while logging on to the FTP server. This parameter is optional.
AccessType

Flags that specify options for an Internet connection. This parameter is optional. This parameter can be one of the following values:

INTERNET_OPEN_TYPE_PRECONFIG = 0 (default)

Retrieves the proxy or direct configuration from the registry.

INTERNET_OPEN_TYPE_DIRECT = 1

Resolves all host names locally.

INTERNET_OPEN_TYPE_PROXY = 3

Passes requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this case, the function uses INTERNET_OPEN_TYPE_DIRECT.

INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4

Retrieves the proxy or direct configuration from the registry and prevents the use of a startup JScript (compatible with ECMA 262 language specification) or Internet Setup (INS) file.

Return Value

Boolean

Remarks

The INet object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

INet Object


GetHTTPFile Method

The GetHTTPFile method retrieves the URL at the specified location.

[VBScript] INet.GetHTTPFile(URL String, [Data Variant], [BytesRead Variant], [AccessType Variant])

Parameters

URL
Specifies the URL to access.
Data
Returns the text at the specified URL. This parameter is optional.
BytesRead
Returns the number of bytes read from the specified URL. This parameter is optional.
AccessType

Flags that specify options for an Internet connection. This parameter is optional. This parameter can be one of the following values:

INTERNET_OPEN_TYPE_PRECONFIG = 0 (default)

Retrieves the proxy or direct configuration from the registry.

INTERNET_OPEN_TYPE_DIRECT = 1

Resolves all host names locally.

INTERNET_OPEN_TYPE_PROXY = 3

Passes requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this case, the function uses INTERNET_OPEN_TYPE_DIRECT.

INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4

Retrieves the proxy or direct configuration from the registry and prevents the use of a startup JScript (compatible with ECMA 262 language specification) or Internet Setup (INS) file.

Return Value

Boolean

Remarks

The INet object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

INet Object


Ping Method

The Ping method pings the specified host and measures the response time.

[VBScript] INet.Ping(Address String, Data Variant, RoundTripMs Variant, [TimeOut Variant])

Parameters

Address
Specifies the destination of the ping request.
Data
Contains the data to send in the request.
RoundTripMs
Number of milliseconds elapsed between sending the request and receiving the reply.
TimeOut
Time-out value for the ping request.

Return Value

Boolean

Examples

The following example shows how to ping the www.microsoft.com server, raising an alert if the ping fails or it takes longer than 500 milliseconds.

[VBScript]
Dim objINet
Dim blnOK, lngRoundTripMs
Dim strData, strError

Set objINet = CreateObject("OpScrUtil.INet")

blnOK = objINet.Ping("www.microsoft.com", strData, lngRoundTripMs)

If (blnOK) Then
    If (lngRoundTripMs > 500) Then
        'Raise an alert
    End If
Else
    strError = objINet.GetError()
    'Create an alert
End If

Set objINet = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

INet Object


MTALogAnalyzer Object

The MTALogAnalyzer object retrieves data from the MTA log file.

Methods

Name | Description
GetCounterString | Gets the performance counter string for the specified MTA log type.
GetError | Gets the most recent error description for the MTALogAnalyzer object.
Initialize | Sets the Microsoft Exchange server name where MTA logs will be analyzed and locates the MTA logs.
LogSummary | Returns a variant array containing rows of MTA log summary information for the specified MTA log type.
ProcessLogDate | Reads and summarizes the MTA log for a specified date.
ProcessLogFileName | Reads and summarizes an MTA log specified by file name.
ProcessPrevDaysLog | Reads and summarizes the previous day's MTA log.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


GetCounterString Method

The GetCounterString method gets the performance counter string for the specified MTA log type.

[VBScript] MTALogAnalyzer.GetCounterString(ID Variant)

Parameters

ID

MTA log type numeric identifier. Valid values include the following:

  • PI_MTA_SMTP_OUT_SENDER = 1001
  • PI_MTA_SMTP_OUT_RECIP = 1002
  • PI_MTA_SMTP_IN_SENDER = 1003
  • PI_MTA_SMTP_IN_RECIP = 1004
  • PI_MTA_ALL_SENDER = 1005
  • PI_MTA_ALL_RECIP = 1006

Return Value

Variant

Examples

The following example shows how to get the performance counter string for SMTP Out Senders.

[VBScript]
Const PI_MTA_SMTP_OUT_SENDER = 1001
Dim objMTALogAnalyzer, strCounterString

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

strCounterString = objMTALogAnalyzer.GetCounterString(PI_MTA_SMTP_OUT_SENDER)

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


GetError Method (MTALogAnalyzer)

The GetError method gets the most recent error description for the MTALogAnalyzer object.

[VBScript] MTALogAnalyzer.GetError()

Parameters

None

Return Value

Variant

Remarks

The GetError method has been deprecated. The following string is always returned: Error information. Use the scripting language's built-in, error-handling mechanism (such as the VBScript Err object) to check for errors.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


Initialize Method

The Initialize method sets the Microsoft Exchange server name where MTA logs will be analyzed and locates the MTA logs.

[VBScript] MTALogAnalyzer.Initialize(ExchangeServer Variant, [LogDir Variant])

Parameters

ExchangeServer
Name of Exchange server where MTA logs will be analyzed.
LogDir
Specifies the complete path to the MTA log files. This parameter is optional.

Return Value

Variant

Remarks

If the logs cannot be located, this method returns False.

Examples

The following example shows how to set the MTALogAnalyzer object to the EXCHSERVER1 Exchange server.

[VBScript]
Dim objMTALogAnalyzer, blnOK

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

blnOK = objMTALogAnalyzer.Initialize("EXCHSERVER1")
If Not(blnOK) Then
    strError = objMTALogAnalyzer.GetError()
End If

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


LogSummary Method

The LogSummary method returns a variant array containing rows of MTA log summary information for the specified MTA log type.

[VBScript] MTALogAnalyzer.LogSummary(MTA_Type Variant, DataOut Variant, RowCount Variant, [TopNN Variant])

Parameters

MTA_Type

Specifies the type of MTA log summary to return. Valid values include the following:

  • PI_MTA_SMTP_OUT_SENDER = 1001
  • PI_MTA_SMTP_OUT_RECIP = 1002
  • PI_MTA_SMTP_IN_SENDER = 1003
  • PI_MTA_SMTP_IN_RECIP = 1004
  • PI_MTA_ALL_SENDER = 1005
  • PI_MTA_ALL_RECIP = 1006
DataOut
Variant array that contains MTA log summary information for a server.
RowCount
Number of MTA log summary information rows returned.
TopNN
Specifies that this method should only return rows with the top NN MTA summary entries, as measured by message count and message size. This parameter is optional.

Return Value

Variant

Examples

The following example shows how to get the previous day's top 100 SMTP Out Sender log summary results for the EXCHSERVER1 Exchange server using the Someone mailbox.

[VBScript]
Const PI_MTA_SMTP_OUT_SENDER = 1001
Dim objMTALogAnalyzer, vntData
Dim lngRowCount, lngIndex, lngMsgCount, lngMB
Dim strError

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

If objMTALogAnalyzer.LogonToMAPI("EXCHSERVER1", "Someone") Then
    If objMTALogAnalyzer.ProcessPrevDaysLog() Then
        If objMTALogAnalyzer.LogSummary(PI_MTA_SMTP_OUT_SENDER, vntData, lngRowCount, 100) Then
            For lngIndex = 0 to lngRowCount - 1
                strObject = vntData(0, lngIndex)
                lngMsgCount = vntData(1, lngIndex)
                lngMB = vntData(2, lngIndex)
                ' Do something with summary information
            Next
        Else
            strError = objMTALogAnalyzer.GetError()
        End If
     Else
        strError = objMTALogAnalyzer.GetError()
     End If
Else
    strError = objMTALogAnalyzer.GetError()
End If

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


ProcessLogDate Method

The ProcessLogDate method reads and summarizes the MTA log for a specified date.

[VBScript] MTALogAnalyzer.ProcessLogDate(Date Variant)

Parameters

Date
Specifies the date of the MTA log to process in format YYYYMMDD.

Return Value

Variant

Examples

The following example shows how to get the MTA log's top 100 SMTP Out Sender log summary results for 12/31/1999 from the EXCHSERVER1 Exchange server using the Someone mailbox.

[VBScript]
Const PI_MTA_SMTP_OUT_SENDER = 1001
Dim objMTALogAnalyzer, vntData
Dim lngRowCount, lngIndex, lngMsgCount, lngMB
Dim strError

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

If objMTALogAnalyzer.LogonToMAPI("EXCHSERVER1", "Someone") Then
    If objMTALogAnalyzer.ProcessLogDate("19991231") Then
        If objMTALogAnalyzer.LogSummary(PI_MTA_SMTP_OUT_SENDER, vntData, lngRowCount, 100) Then
            For lngIndex = 0 to lngRowCount - 1
                strObject = vntData(0, lngIndex)
                lngMsgCount = vntData(1, lngIndex)
                lngMB = vntData(2, lngIndex)
                ' Do something with summary information
            Next
        Else
            strError = objMTALogAnalyzer.GetError()
        End If
    Else
        strError = objMTALogAnalyzer.GetError()
    End If
Else
    strError = objMTALogAnalyzer.GetError()
End If

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


ProcessLogFileName Method

The ProcessLogFileName method reads and summarizes an MTA log specified by file name.

[VBScript] MTALogAnalyzer.ProcessLogFileName(MTALogFileName Variant)

Parameters

MTALogFileName
Specifies the full path to the MTA log file to process.

Return Value

Variant

Examples

The following example shows how to get the MTA log's top 100 SMTP Out Sender log summary results for the C:\Exchange\tracking.log\19991231.log log file from the EXCHSERVER1 Exchange server using the Someone mailbox.

[VBScript]
Const PI_MTA_SMTP_OUT_SENDER = 1001
Dim objMTALogAnalyzer, vntData
Dim lngRowCount, lngIndex, lngMsgCount, lngMB
Dim strError

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

If objMTALogAnalyzer.LogonToMAPI("EXCHSERVER1", "Someone") Then
    If objMTALogAnalyzer.ProcessLogFileName("C:\Exchange\tracking.log\19991231.log") Then
        If objMTALogAnalyzer.LogSummary(PI_MTA_SMTP_OUT_SENDER, vntData, lngRowCount, 100) Then
            For lngIndex = 0 to lngRowCount - 1
                strObject = vntData(0, lngIndex)
                lngMsgCount = vntData(1, lngIndex)
                lngMB = vntData(2, lngIndex)
                ' Do something with summary information
            Next
        Else
            strError = objMTALogAnalyzer.GetError()
        End If
    Else
        strError = objMTALogAnalyzer.GetError()
    End If
Else
    strError = objMTALogAnalyzer.GetError()
End If

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


ProcessPrevDaysLog Method

The ProcessPrevDaysLog method reads and summarizes the previous day's MTA log.

[VBScript] MTALogAnalyzer.ProcessPrevDaysLog()

Parameters

None

Return Value

Variant

Examples

The following example shows how to get the previous day's top 100 SMTP Out Sender log summary results for the EXCHSERVER1 Exchange server using the Someone mailbox.

[VBScript]
Const PI_MTA_SMTP_OUT_SENDER = 1001
Dim objMTALogAnalyzer, vntData
Dim lngRowCount, lngIndex, lngMsgCount, lngMB
Dim strError

Set objMTALogAnalyzer = CreateObject("McExchg.MTALogAnalyzer")

If objMTALogAnalyzer.LogonToMAPI("EXCHSERVER1", "Someone") Then
    If objMTALogAnalyzer.ProcessPrevDaysLog() Then
        If objMTALogAnalyzer.LogSummary(PI_MTA_SMTP_OUT_SENDER, vntData, lngRowCount, 100) Then
            For lngIndex = 0 to lngRowCount - 1
                strObject = vntData(0, lngIndex)
                lngMsgCount = vntData(1, lngIndex)
                lngMB = vntData(2, lngIndex)
                ' Do something with summary information
            Next
        Else
            strError = objMTALogAnalyzer.GetError()
        End If
    Else
        strError = objMTALogAnalyzer.GetError()
    End If
Else
    strError = objMTALogAnalyzer.GetError()
End If

Set objMTALogAnalyzer = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

MTALogAnalyzer Object


PagerJobQueue Object

The PagerJobQueue object configures the modem paging service and sends page messages.

Methods

Name | Description
AbortClearQueue | Aborts the page currently in progress and moves all waiting pages to the Failed folder.
ConfigureServices | Shows a dialog box that lets you configure the modem paging software. This dialog box allows you to set the modem used to send pages and configure individual paging services.
GetError | Gets the most recent error for the PagerJobQueue object.
GetPagerService | Gets the default paging service as specified by a previous call to the SetPagerService method.
ProcessPageJobQueue | Instructs the PagerJobQueue object to process any waiting pages in the Outbox folder.
SendMessage | Submits an alphanumeric pager message for processing by the modem paging software.
SetGroomAge | Sets the groom age setting (in the registry) for the PagerJobQueue object.
SetPagerService | Sets the default paging service as specified in the registry.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


AbortClearQueue Method

The AbortClearQueue method stops modem paging and clears the queue of waiting pages. The cleared pages are moved to the Failed folder and updated with a status indicating that the user requested that the pager message be aborted.

[VBScript] PagerJobQueue.AbortClearQueue(ServiceName string)

Parameters

ServiceName
Name of the service.

Return Value

Boolean

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


ConfigureServices Method

The ConfigureServices method shows a dialog box that lets you configure the modem paging software. This dialog box allows you to set the modem used to send pages and configure individual paging services.

[VBScript] PagerJobQueue.ConfigureServices()

Parameters

None

Return Value

Boolean

Examples

The following example shows how to configure modem paging.

[VBScript]
Dim objPagerJobQueue, blnOK

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

blnOK = objPagerJobQueue.ConfigureServices()

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


GetError Method (PagerJobQueue)

The GetError method gets the most recent error for the PagerJobQueue object.

[VBScript] PagerJobQueue.GetError()

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Dim objPagerJobQueue
Dim strErrorMsg

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

If Not(objPagerJobQueue.ConfigureServices()) Then
    strErrorMsg = "Configure services failed. The error is " & objPagerJobQueue.GetError()
End If

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


GetPagerService Method

The GetPagerService method gets the default paging service as specified by a previous call to the SetPagerService method.

[VBScript] PagerJobQueue.GetPagerService()

Parameters

None

Return Value

String

Examples

The following example shows how to get the PagerJobQueue object default service provider.

[VBScript]
Dim objPagerJobQueue, strServiceProvider

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

strServiceProvider = objPagerJobQueue.GetPagerService()

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


ProcessPageJobQueue Method

The ProcessPageJobQueue method instructs the PagerJobQueue object to process any waiting pages in the Outbox folder.

[VBScript] PagerJobQueue.ProcessPageJobQueue()

Parameters

None

Return Value

Boolean

Remarks

The ProcessPageJobQueue method should not be needed under normal circumstances because pager job queue processing is performed as part of the SendMessage method.

Examples

The following example shows how to process any waiting pages in the Outbox folder.

[VBScript]
Dim objPagerJobQueue, blnOK

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

blnOK = objPagerJobQueue.ProcessPageJobQueue()

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


SendMessage Method

The SendMessage method submits an alphanumeric pager message for processing by the modem paging software.

[VBScript] PagerJobQueue.SendMessage(strService String, strOperatorID String, strMessage String, [lngPriority Variant])

Parameters

strService
One of the services defined in the modem paging software. Use the ConfigureServices method to configure paging services.
strOperatorID
Unique number for the recipient of the message (PIN).
strMessage
Actual text of the message to be sent.
varPriority
Number that represents the relative importance of the message. Messages with higher priority values are sent before other pages. This parameter is optional.

Return Value

Boolean

Examples

The following example shows how to send a page set to priority 50 with the text Hello World to pager 5551212 on the Contoso, Ltd. service.

[VBScript]
Dim objPagerJobQueue, blnOK

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

blnOK = objPagerJobQueue.SendMessage("Contoso, Ltd.", "5551212", "Hello world", 50)

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


SetGroomAge Method

The SetGroomAge method sets the groom age setting (in the registry) for the PagerJobQueue object.

[VBScript] PagerJobQueue.SetGroomAge(lngAgeInDays Long)

Parameters

lngAgeInDays
Maximum age of messages in the Sent and Failed folders. Messages older than this will be deleted. The range for this setting is -1 to 7200. Use a value of -1 to indicate that messages should never be deleted.

Return Value

Boolean

Remarks

The range setting determines the age at which sent and failed pages will be deleted from their respective folders in the OnePoint\ModemPaging directory.

Examples

The following example shows how to set the PagerJobQueue object to delete sent or failed messages after 60 days.

[VBScript]
Dim objPagerJobQueue, blnOK

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

blnOK = objPagerJobQueue.SetGroomAge(60)

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


SetPagerService Method

The SetPagerService method sets the default paging service as specified in the registry.

[VBScript] PagerJobQueue.SetPagerService(strPagerService String)

Parameters

strPagerService
Name of the pager service that has been set up using the ConfigureServices method.

Return Value

Boolean

Examples

The following example shows how to set the PagerJobQueue object to use the Contoso, Ltd. service.

[VBScript]
Dim objPagerJobQueue, blnOK

Set objPagerJobQueue = CreateObject("OPScrUtil.PagerJobQueue")

blnOK = objPagerJobQueue.SetPagerService("Contoso, Ltd.")

Set objPagerJobQueue = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

PagerJobQueue Object


SCManager Object (Deprecated)

The SCManager object controls services on the computer. This object has been deprecated and should not be used when creating new scripts. It is included only to support existing scripts. For new scripts, see Using Operating System APIs in Scripts.

Methods

Name | Description
BounceService | Starts and stops the specified Microsoft Windows NT service and queries the service status to ensure that the service has started.
ContinueService | Sends a continue control code to a Windows NT service and verifies that the service has entered a running state.
GetError | Gets the most recent error description for the SCManager object.
GetServiceConfig | Gets the configuration parameters of the specified service.
GetServiceStatus | Gets the status of the specified service.
PauseService | Sends a pause control code to a Windows NT service and verifies that the service has entered a paused state.
StartService | Sends a service start control request to the specified Windows NT service and queries the service status to ensure that the service has started.
StopService | Sends a service stop control request to the specified Windows NT service and queries the service status to ensure that the service has stopped.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


BounceService Method

The BounceService method starts and stops the specified Windows NT service and queries the service status to ensure that the service has started.

[VBScript] SCManager.BounceService(ServiceName Variant, [ComputerName Variant], [Arguments Variant])

Parameters

ServiceName
Specifies the name of the service to start.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.
Arguments
Specifies arguments to the service being bounced. This parameter is optional.

Return Value

Boolean

Remarks

The BounceService method times out after two minutes.

Examples

The following example shows how to bounce the messenger service on the local computer.

[VBScript]
Dim objSCManager, blnOK

Set objSCManager = CreateObject("OpScrUtil.SCManager")

blnOK = objSCManager.BounceService("Messenger", "")

Set objSCManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


ContinueService Method

The ContinueService method sends a continue control code to a Windows NT service and verifies that the service has entered a running state.

[VBScript] SCManager.ContinueService (ServiceName String, [ComputerName Variant])

Parameters

ServiceName
Specifies the name of the service to continue.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The ContinueService method times out after two minutes.

The SCManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


GetError Method (SCManager)

The GetError method gets the most recent error description for the SCManager object.

[VBScript] SCManager.GetError()

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Function StartMessengerService()
    Dim objSCManager
    Dim strErrorMsg

    Set objSCManager = CreateObject("OpScrUtil.SCManager")

    If (objSCManager.StartService("messenger")) Then
        strErrorMsg = ""
    Else
        strErrorMsg = "Service did not start. The error is " & objSCManager.GetError()
    End If

    Set objSCManager = Nothing

    StartMessengerService = strMsg
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


GetServiceConfig Method

The GetServiceConfig method gets the configuration parameters of the specified service.

[VBScript] SCManager.GetServiceConfig(ServiceName String, Request String, OutInfo Variant, [ComputerName Variant])

Parameters

ServiceName
Specifies the name of the service to retrieve configuration information.
Request

Specifies which configuration item to retrieve. Possible values are Type, Start Type, Error Control, Binary Path, Dependencies, Display Name, Load Order Group, and Start Name.

OutInfo
Returns the requested configuration item.
ComputerName
Specifies the name of the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Examples

The following example shows how to get the binary path for the messenger service on the local computer.

[VBScript]
Dim objSCManager, blnOK, vntPath

Set objSCManager = CreateObject("OpScrUtil.SCManager")

blnOK = objSCManager.GetServiceConfig("messenger", "binary path", vntPath, "")

Set objSCManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


GetServiceStatus Method

The GetServiceStatus method gets the status of the specified service.

[VBScript] SCManager.GetServiceStatus(ServiceName Variant, ServiceStatus Variant, [ServiceStatusNumber Variant], [ComputerName Variant])

Parameters

ServiceName
Specifies the name of the service to retrieve status.
ServiceStatus
Returns the status of the specified service as a string. Possible values are Stopped, Running, Start Pending, Stop Pending, Continue Pending, Pause Pending, and Paused.
ServiceStatusNumber
Returns the status of the specified service as a number. This parameter is optional. Possible values are 1 - Stopped, 2 - Start Pending, 3 - Stop Pending, 4 - Running, 5 - Continue Pending, 6 - Pause Pending, and 7 - Paused.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The SCManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


PauseService Method

The PauseService method sends a pause control code to a Windows NT service and verifies that the service has entered a paused state.

[VBScript] SCManager.PauseService (ServiceName Variant, [ComputerName Variant])

Parameters

ServiceName
Specifies the name of the service to pause.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The PauseService method times out after two minutes.

The SCManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


StartService Method

The StartService method sends a service start control request to the specified Windows NT service and queries the service status to ensure that the service has started.

[VBScript] SCManager.StartService(ServiceName Variant, [ComputerName Variant], [Arguments Variant])

Parameters

ServiceName
Specifies the name of the service to start.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.
Arguments
Specifies arguments to the service being started. This parameter is optional.

Return Value

Boolean

Remarks

The StartService method times out after two minutes.

The SCManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


StopService Method

The StopService method sends a service stop control request to the specified Windows NT service and queries the service status to ensure that the service has stopped.

[VBScript] SCManager.StopService(ServiceName Variant, [ComputerName Variant])

Parameters

ServiceName
Specifies the name of the service to stop.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameters is an empty string, the local computer is the target.

Return Value

Boolean

Remarks

The StopService method times out after two minutes.

The SCManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SCManager Object


SystemManager Object (Deprecated)

The SystemManager object gathers information about the computer. It also allows scripts to restart or shut down the computer or to log off a user. This object has been deprecated and should not be used when creating new scripts. It is included only to support existing scripts. For new scripts, see Using Operating System APIs in Scripts.

Methods

Name | Description
ForceLogoff | Forces the current user to be logged out of Windows NT.
ForceReboot | Forces Windows NT to shut down and restart.
ForceShutdown | Forces Windows NT to shut down.
GetError | Gets the most recent error description for the SystemManager object.
LockWorkstation | Locks the workstation so that it is protected from unauthorized use.
RequestLogoff | Sends a request to the system to log off the currently logged on user.
RequestReboot | Sends a request to reboot the local computer.
RequestShutdown | Sends a request to shut down the local computer.

Properties

Name | Description
Domain | Gets a string containing the name of the domain or workgroup to which the computer belongs.
LoggedOnUsers | Gets the number of currently logged-on users.
OS | Gets a string identifying the operating system.
OSBuildNumber | Gets the operating system build number.
OSMajorVersion | Gets the operating system major version.
OSMinorVersion | Gets the operating system minor version.
PlatformId | Gets the operating system platform ID.
ServicePackInfo | Gets information about installed service packs.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


ForceLogoff Method

The ForceLogoff method forces the current user to be logged out of Windows NT.

[VBScript] SystemManager.ForceLogoff()

Parameters

None

Return Value

Boolean

Examples

The following example shows how to force the currently logged-on user to log out.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = objSystemManager.ForceLogoff()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


ForceReboot Method

The ForceReboot method forces Windows NT to shut down and restart.

[VBScript] SystemManager.ForceReboot()

Parameters

None

Return Value

Boolean

Examples

The following example shows how to force Windows NT to shut down and restart.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = objSystemManager.ForceReboot()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


ForceShutdown Method

The ForceShutdown method forces Windows NT to shut down.

[VBScript] SystemManager.ForceShutdown()

Parameters

None

Return Value

Boolean

Examples

The following example shows how to force Windows NT to shut down.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = objSystemManager.ForceShutdown()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


GetError Method (SystemManager)

The GetError method gets the most recent error description for the SystemManager object.

[VBScript] SystemManager.GetError()

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Function Lock()
    Dim objSystemManager
    Dim strErrorMsg

    strErrorMsg = ""

    Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

    If Not(objSystemManager.LockWorkstation()) Then
        strErrorMsg = "Workstation was not locked. The error is " & objSystemManager.GetError()
    End If

    Set objSystemManager = Nothing

    Lock = strErrorMsg
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


LockWorkstation Method

The LockWorkstation method locks the workstation so that it is protected from unauthorized use.

[VBScript] SystemManager.LockWorkstation()

Return Value

Boolean

Examples

The following example shows how to lock the workstation.

[VBScript]
Function Lock()
    Dim objSystemManager
    Dim strErrorMsg

    strErrorMsg = ""

    Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

    If Not(objSystemManager.LockWorkstation()) Then
        strErrorMsg = "Workstation was not locked. The error is " & objSystemManager.GetError()
    End If

    Set objSystemManager = Nothing

    Lock = strErrorMsg
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


RequestLogoff Method

The RequestLogoff method sends a request to the system to log off the currently logged-on user.

[VBScript] SystemManager.RequestLogoff()

Parameters

None

Return Value

Boolean

Examples

The following example shows how to request that the currently logged-on user be logged off.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = obj.RequestLogoff()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


RequestReboot Method

The RequestReboot method sends a request to reboot the local computer.

[VBScript] SystemManager.RequestReboot()

Parameters

None

Return Value

Long

Examples

The following example shows how to send a request to reboot the local computer.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = objSystemManager.RequestReboot()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


RequestShutdown Method

The RequestShutdown method sends a request to shut down the local computer.

[VBScript] SystemManager.RequestShutdown()

Return Value

Long

Examples

The following example shows how to send a request to shut down the local computer.

[VBScript]
Dim objSystemManager, blnOK

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

blnOK = objSystemManager.RequestShutdown()

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


Domain Property

The Domain property gets a string containing the name of the domain or workgroup to which the computer belongs.

[VBScript] SystemManager.Domain

Access

Read/Write

Return Value

String

Remarks

The SystemManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


LoggedOnUsers Property

The LoggedOnUsers property gets the number of currently logged-on users.

[VBScript] SystemManager.LoggedOnUsers

Access

Read/Write

Return Value

Long

Examples

The following example shows how to access the number of logged-on users.

[VBScript]
Dim objSystemManager, lngLoggedOnUsers

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

lngLoggedOnUsers = objSystemManager.LoggedOnUsers

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


OS Property

The OS property gets a string identifying the operating system.

[VBScript] SystemManager.OS

Access

Read/Write

Return Value

String

Remarks

The SystemManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


OSBuildNumber Property

The OSBuildNumber property gets the operating system build number.

[VBScript] SystemManager.OSBuildNumber

Access

Read/Write

Return Value

Long

Remarks

The SystemManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


OSMajorVersion Property

The OSMajorVersion property gets the operating system major version.

[VBScript] SystemManager.OSMajorVersion

Access

Read/Write

Return Value

Long

Remarks

The SystemManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


OSMinorVersion Property

The OSMinorVersion property gets the operating system minor version.

[VBScript] SystemManager.OSMinorVersion

Access

Read/Write

Return Value

Long

Remarks

The SystemManager object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


PlatformId Property

The PlatformId property gets the operating system platform ID.

[VBScript] SystemManager.PlatformId

Access

Read/Write

Return Value

Long

Examples

The following example shows how to access the operating system platform ID.

[VBScript]
Dim lngID, objSystemManager

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

lngID = objSystemManager.PlatformId

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


ServicePackInfo Property

The ServicePackInfo property gets information about installed service packs.

[VBScript] SystemManager.ServicePackInfo

Access

Read/Write

Return Value

String

Remarks

For Windows NT and Windows 2000, the return value is a string (such as Service Pack 3) that indicates the latest service pack installed on the system. If no service pack has been installed, the string is empty. For Microsoft Windows 9x, the return value is a string that provides additional information about the operating system.

Examples

The following example shows how to access the service pack information.

[VBScript]
Dim objSystemManager, strSPInfo

Set objSystemManager = CreateObject("OpScrUtil.SystemManager")

strSPInfo = objSystemManager.ServicePackInfo

Set objSystemManager = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

SystemManager Object


TermServer Object

The TermServer object retrieves information about Terminal Server sessions.

Methods

Name | Description
GetError | Gets the most recent error description for the TermServer object.
GetSessionIDFromWinStation | Gets the unique identifier (ID) of a session from a given WinStation name.
GetUserNameFromSessionID | Gets the user name from a specified session ID.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

TermServer Object

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


GetError Method (TermServer)

The GetError method gets the most recent error description for the TermServer object.

[VBScript] TermServer.GetError()

Parameters

None

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Function GetAccountName(lngSessionID)
    Dim objTermServer, blnOK, strUserName

    Set objTermServer = CreateObject("OpScrUtil.TermServer")

    blnOK = objTermServer.GetUserNameFromSessionID(lngSessionID, strUserName)
    If (blnOK = False) Then
        strUserName = "GetUserNameFromSessionID Failed. The error is " & objTermServer.GetError()
    End If

    Set objTermServer = Nothing

    GetAccountName = strUserName
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

TermServer Object


GetSessionIDFromWinStation Method

The GetSessionIDFromWinStation method gets the unique identifier (ID) of a session from a given WinStation name.

[VBScript] TermServer.GetSessionIDFromWinStation(WinStation Variant, sessionID Variant, [ComputerName Variant])

Parameters

WinStation
Name of the specified session.
SessionID
Session identifier.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Examples

The following example shows how to get the session ID for a given session name.

[VBScript]
Function GetSessionID(strWinStationName)
    Dim objTermServer, lngSessionID, blnOK

    Set objTermServer = CreateObject("OpScrUtil.TermServer")

    blnOK = objTermServer.GetSessionIDFromWinStation(strWinStationName, lngSessionID)
    If Not(blnOK) Then
        lngSessionID = -1
    End If

    Set objTermServer = Nothing

    GetSessionID = lngSessionID
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

TermServer Object


GetUserNameFromSessionID Method

The GetUserNameFromSessionID method gets the user name from a specified session ID.

[VBScript] TermServer.GetUserNameFromSessionID(SessionID Variant, UserName Variant, [ComputerName Variant])

Parameters

SessionID
Specifies the ID of the session.
UserName
Specifies the name of the user associated with the SessionID parameter.
ComputerName
Specifies the target computer. This parameter is optional. If the target computer is not specified or the parameter is an empty string, the local computer is the target.

Return Value

Boolean

Examples

The following example shows how to get the user name associated with the given session ID.

[VBScript]
Function GetAccountName(lngSessionID)
    Dim objTermServer, blnOK, strUserName

    Set objTermServer = CreateObject("OpScrUtil.TermServer")

    blnOK = objTermServer.GetUserNameFromSessionID(lngSessionID, strUserName)
    If (blnOK = False) Then
        strUserName = "GetUserNameFromSessionID Failed. The error is " & objTermServer.GetError()
    End If

    Set objTermServer = Nothing

    GetAccountName = strUserName
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

TermServer Object


Utility Object (Deprecated)

The Utility object provides general-purpose functionality not provided by other MOM objects. This object has been deprecated and should not be used when creating new scripts. It is included only to support existing scripts. For new scripts, see Using Operating System APIs in Scripts.

Methods

Name | Description
CreateProcess | Creates a new Windows NT process.
ExpandEnvironmentStrings | Expands environment-variable strings to their defined values.
GetEnviron | Gets the specified environment variable from the environment of the current process.
GetError | Gets the most recent error description for the Utility object.
LogEvent | Logs a generic event to the Windows NT application event log using the MOM event source.
Sleep | Suspends execution of the script for the specified number of seconds.
SleepMs | Suspends execution of the script for the specified number of milliseconds.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.


CreateProcess Method

The CreateProcess method creates a new Windows NT process. This method optionally waits for the process to exit and returns the exit code. If the process does not end within the specified time-out period, it can be forcefully terminated.

[VBScript] Utility.CreateProcess(ExePath String, CommandLine String, Wait Boolean, [TimeOut Variant], [ForceTermination Variant], [ExitCode Variant])

Parameters

ExePath
Specifies the module to execute. This parameter can be NULL, in which case the module name must be the first white space-delimited token in ExePath.
CommandLine
Specifies the command line to execute. This parameter can be NULL, in which case the ExePath parameter is used as the command line.
Wait
Specifies whether the function waits for the launched process to terminate.
TimeOut
Specifies the length of time, in seconds, to wait for the launched process if the Wait parameter was specified. This parameter is optional and defaults to 120 (the default is adjustable in the registry).
ForceTermination
Specifies whether the function terminates the launched process after the time-out has been reached. This parameter is optional. This parameter returns True or False to indicate whether the process was forcibly terminated.
ExitCode
Returns the exit code of the launched process. This parameter is optional and is not available if Wait is False.

Return Value

Boolean

Remarks

The Utility object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object


ExpandEnvironmentStrings Method

The ExpandEnvironmentStrings method expands environment-variable strings to their defined values.

[VBScript] Utility.ExpandEnvironmentStrings(Instring Variant)

Parameters

Instring
Specifies the name of the environment variable to be expanded. The name must be preceded and followed by the percent character (%).

Return Value

String

Examples

The following example shows how to get an expanded environment variable.

[VBScript]
Function GetProgramFolder()
    Dim objUtil, strEnvValue

    Set objUtil = CreateObject("OpScrUtil.Utility")

    strEnvValue = objUtil.ExpandEnvironmentStrings("%PROGRAMFILES%") ' must include the "%"

    Set objUtil = Nothing

    GetProgramFolder = strEnvValue
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object, GetEnviron Method


GetEnviron Method

The GetEnviron method gets the specified environment variable from the environment of the current process.

[VBScript] Utility.GetEnviron(EnvironmentVariable String)

Parameters

EnvironmentVariable
Specifies the environment variable to retrieve.

Return Value

String

Examples

The following example shows how to get the PATH environment variable.

[VBScript]
Function GetPath()
    Dim objUtil, strPath

    Set objUtil = CreateObject("OpScrUtil.Utility")

    strPath = objUtil.GetEnviron("PATH")

    Set objUtil = Nothing

    GetPath = strPath
End Function

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object, ExpandEnvironmentStrings Method


GetError Method (Utility)

The GetError method gets the most recent error description for the Utility object.

[VBScript] Utility.GetError()

Parameters

None

Return Value

String

Examples

The following example shows how to get an error after a function fails.

[VBScript]
Dim objUtil
Dim strErrorMsg

Set objUtil = CreateObject("OpScrUtil.Utility")

If Not(objUtil.Sleep(5)) Then
    strErrorMsg = "Sleep failed. The error is " & objUtil.GetError()
End If

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object


LogEvent Method

The LogEvent method logs a generic event to the Windows NT application event log using the MOM event source.

[VBScript] Utility.LogEvent(Description String, [Severity Variant])

Parameters

Description
Text of the event that will be logged to the event log.
Severity

Severity level of the Windows NT event to be logged. This parameter is optional and can be one of the following values:

  • "Success" or 0

  • "Error" or 1
  • "Warning" or 2
  • "Information" or 4
  • "Audit Success" or 8
  • "Audit Failure" or 16

Return Value

Boolean

Remarks

The Utility object should not be used when creating new scripts. It is included only to support existing scripts. For more information about equivalent APIs, see Using Operating System APIs in Scripts.

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object


Sleep Method

The Sleep method suspends execution of the script for the specified number of seconds.

[VBScript] Utility.Sleep(Seconds Long)

Parameters

Seconds
Specifies the number of seconds to suspend the script.

Return Value

None

Examples

The following example shows how to suspend the script for two seconds.

[VBScript]
Dim objUtil

Set objUtil = CreateObject("OpScrUtil.Utility")

objUtil.Sleep(2)

Set objUtil = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 or later
Version: Requires MOM 1.0 SP1

See Also

Utility Object


SleepMs Method

The SleepMs method suspends execution of the script for the specified number of milliseconds.

[VBScript] Utility.SleepMs(MilliSeconds Long)

Parameters

Milliseconds
Specifies the number of milliseconds to suspend the script.

Return Value

None

Examples

The following example shows how to suspend the script for 2000 milliseconds.

[VBScript]
Dim objUtil

Set objUtil = CreateObject("OpScrUtil.Utility")

objUtil.SleepMs(2000)

Set objUtil = Nothing

Requirements

Windows NT/2000: Requires Windows 2000 later
Version: Requires MOM 1.0 SP1

See Also

Utility Object