Microsoft Identity Integration Server 2003 Developer Reference

Example: Getting the Properties of All Management Agents

The following Visual Basic Scripting Edition (VBScript)example shows how to get the properties of all the management agents on a server. You can use this example to retrieve information about the management agents, such as the name, run profiles, and the details of a specific run.

The example first retrieves the management agent collection and then enumerates through the collection to get the properties of each management agent.

Option Explicit

On Error Resume Next

Const PktPrivacy = 6

Dim ManagementAgentSet  
Dim ManagementAgent	 

Set Service = GetObject("winmgmts:{authenticationLevel=PktPrivacy}!root\MicrosoftIdentityIntegrationServer")
Set ManagementAgentSet = Service.ExecQuery("Select * from MIIS_ManagementAgent")

For each ManagementAgent in ManagementAgentSet

	WScript.Echo "Name		: " & ManagementAgent.Name

	WScript.Echo "GUID		: " & ManagementAgent.Guid

	WScript.Echo "Type		: " & ManagementAgent.Type

	If ManagementAgent.RunProfile() = "" then

		WScript.Echo "No Run Profiles configured for this management agent." _
						& vbcrlf
	Else

		WScript.Echo "Run Profile Details"

		WScript.Echo "	Name	 : " & ManagementAgent.RunProfile()

		WScript.Echo "	Run Number : " & ManagementAgent.RunNumber()

		WScript.Echo "	Status	 : " & ManagementAgent.RunStatus()

		WScript.Echo "	Start Time : " & ManagementAgent.RunStartTime()

		WScript.Echo "	End Time   : " & ManagementAgent.RunEndTime()

		WScript.Echo "	Run Details: " & ManagementAgent.RunDetails() & vbcrlf

	End If	 

Next

Sub ErrorHandler (ErrorMessage)
  WScript.Echo ErrorMessage
  WScript.Quit(1)
End Sub

See Also

Enabling Security in Scripts