How to: Run a Management Agent with a Specified Run Profile
Although you can run a management agent from Synchronization Service Manager, with the Windows Management Instrumentation (WMI) Provider, you can also run a management agent from a script.
The advantages of running a management agent from a script:
By running a script at a specified time using the Scheduled Tasks feature of Windows Server 2003, you can minimize the impact on your infrastructure.
You can write one script that accepts named arguments to run any management agent. For more information, see How to: Specify Management Agents from a Command Line.
You can sequentially run several management agents through a command file that runs a management agent only if the previous management agent run was successful. For more information, see How to: Run Several Management Agents from a Command File.
The following Microsoft Visual Basic Scripting Edition (VBScript) example shows how to create a script that runs a management agent with a specified run profile. The script runs the Fabrikam HR MA management agent with a full import run profile and then returns a value. You can use this return value to determine if you can run other scripts.
Option Explicit
On Error Resume Next
Const PktPrivacy = 6 ' Authentication Level
Dim Service ' Connection object
Dim ManagementAgent ' Management agent object
Dim Status ' String for the status
Dim ErrorLevel ' Return code
ErrorLevel = 1
Set Service = GetObject("winmgmts:{authenticationLevel=PktPrivacy}!root\MicrosoftIdentityIntegrationServer")
Set ManagementAgent = Service.Get("MIIS_ManagementAgent.Name='Fabrikam HR MA'")
Status = ManagementAgent.Execute("Full Import")
If Status = "success" then
ErrorLevel = 0
End if
WScript.Echo "Management Agent Run Result: " & Status
Sub ErrorHandler (ErrorMessage)
WScript.Echo ErrorMessage
WScript.Quit(1)
End Sub
See Also
Concepts
How to: Specify Management Agents from a Command Line
How to: Run Several Management Agents from a Command File
How to: Enable Security in Scripts
Script Examples