How to: Run Several Management Agents from a Command File

You can run several management agents (MA) in a script. However, you may want to run a specified management agent only if the previous management agent run was successful. If the previous management agent run fails, you can stop processing. You can create a command file that can do this for you.

The following example contains a command file that runs a management agent only if the previous management agent run was successful. The example assumes that you have a script file called RunMA.vbs that runs a specified management agent and returns a value. The script uses named arguments to determine the management agent and run profile to run. For more information about creating a script file that uses named arguments, see How to: Specify Management Agents from a Command Line.

The example runs the Fabrikam HR MA management agent with the full import run profile. If this management agent run is successful, the Fabrikam AD MA management agent with a delta synchronization run profile is run. If the management agent run fails, no further processing occurs.

If the first two management agent runs are successful, the Fabrikam LDAP Data Interchange Format MA management agent is run.

setlocal
set zworkdir=%~dp0
pushd %zworkdir%

RunMA /MA:"Fabrikam HR MA" /RunProfile:"Full Import"
if {%errorlevel%} NEQ {0} (echo Error[%ErrorLevel%]: command file failed) & (goto exit_script)

RunMA /MA:"Fabrikam AD MA" /RunProfile:"Delta Synchronization"
if {%errorlevel%} NEQ {0} (echo Error[%errorlevel%]: command file failed) & (goto exit_script)

RunMA /MA:"Fabrikam LDAP Data Interchange Format MA" /RunProfile:"Full Import CSV"
if {%errorlevel%} NEQ {0} (echo Error[%errorlevel%]: command file failed) & (goto exit_script)

:exit_script
popd
endlocal

See Also

Concepts

How to: Run a Management Agent with a Specified Run Profile
How to: Specify Management Agents from a Command Line
Script Examples
How to: Enable Security in Scripts