Microsoft KB Archive/297884

= How to Use the Zscript &quot;-define&quot; Parameter to Control Management Agents at Run-Time =

Article ID: 297884

Article Last Modified on 1/18/2006

-

APPLIES TO


 * Microsoft Metadirectory Services 2.1
 * Microsoft Metadirectory Services 2.2 Service Pack 1
 * Microsoft Metadirectory Services 2.2 Service Pack 1

-



This article was previously published under Q297884



SUMMARY
When you use the -define parameter in the Zscript command line, you can accommodate different run-time conditions by use of a single Microsoft Metadirectory Services Management Agent (MA). Generally, a parameter that is sent to the originating .cmd file sets one or more variables on the Zscript command line. These variables are then used in the Mascript.scr template to configure attribute values at run-time that are referenced by the Cdir_AD.dll file if the computer is running the Active Directory MA, or by IMPORTT (if the computer is running a standard MA).



MORE INFORMATION
Use the following sample batch file to set up different behaviours for the same Active Directory MA. If the batch file is called with the parameter Weekday, the MA runs in Delta mode. If the batch file is called with the parameter Weekend, the MA runs in Full mode. By using this technique, you can lock down run-time behavior to prevent any unintended configuration changes that are made with the Compass client from affecting the necessary outcome of the MA.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Batch File Code
In a file named &quot;My_Batch_File.bat&quot;, add the following code: @ECHO OFF REM ========================== REM Script to run the Active Directory Management Agent REM REM Accepts one parameter REM usage: MMS-AD-Script.cmd Weekend | Weekday REM REM    WEEKDAY - Runs the Management Agent in delta mode REM WEEKEND - Runs the Management Agent in full mode REM ==========================

REM ========================== IF /I '%1' == 'weekend' GOTO :WEEKEND IF /I '%1' == 'weekday' GOTO :WEEKDAY GOTO :EOF REM ==========================
 * WEEKDAY

ECHO. ECHO Processing WEEKDAY script REM *** Run Management Agent in delta mode ECHO. ECHO Starting Management Agent ECHO %DATE% %TIME% @ZSCRIPT -DN &quot;ma=Primary MA,DsaName=mmsserver,ou=Servers,dc=microsoft,dc=com&quot; -DEFINE &quot;DELTA=TRUE&quot; GOTO :EOF REM ==========================
 * WEEKEND

ECHO. ECHO Processing WEEKEND script REM *** Run Management Agent in full mode ECHO. ECHO Starting Management Agent ECHO %DATE% %TIME% @ZSCRIPT -DN &quot;ma=Primary MA,DsaName=mmsserver,ou=Servers,dc=microsoft,dc=com&quot; -DEFINE &quot;DELTA=FALSE&quot; GOTO :EOF

MAScript Code
The following Mascript.scr file would then behave according to the value of the defined variable &quot;DELTA&quot;. cd %zcDsDirectory% output -append adma.log echo Starting MAScript IF %DELTA% = TRUE THEN SET zcDsRole = &quot;LINK&quot; SET zcDsPerformDiscovery = &quot;TRUE&quot; SET zcDsPerformMetaSync = &quot;TRUE&quot; SET zcMAProcessUsers = &quot;TRUE&quot; SET zcDSImportDelta = &quot;TRUE&quot; VSET DeltaScheduledUpdate = &quot;TRUE&quot; ENDIF IF %DELTA% = FALSE THEN SET zcDsRole = &quot;LINK&quot; SET zcDsPerformDiscovery = &quot;TRUE&quot; SET zcDsPerformMetaSync = &quot;TRUE&quot; SET zcMAProcessUsers = &quot;TRUE&quot; SET zcDSImportDelta = &quot;FALSE&quot; VSET FullScheduledUpdate = &quot;TRUE&quot; ENDIF if %DeltaScheduledUpdate% = TRUE then echo echo * Scheduled delta metadirectory and Active Directory update echo ************************************************************** SET zcDsImportDelta = &quot;TRUE&quot; SET zcOperateMA = 1 endif if %FullScheduledUpdate% = TRUE then echo ************************************************************** echo * Scheduled full metadirectory and Active Directory update echo ************************************************************** SET zcDsImportDelta = &quot;FALSE&quot; SET zcOperateMA = 1 endif To set up a working scenario:  Edit the Path Environment Variable to include c:\zoomserv\bin. For more information about how to change environment variables in Windows 2000, refer to the Windows 2000 Help topic, &quot;To add or change the values of environment variables.&quot; Name the batch file my_batch_file.bat and place it in the working directory of the Active Directory MA. Copy the sample code from the &quot;MAScript Code&quot; section in this article to the MAScript of the Active Directory MA:  In the Compass utility, select the Active Directory MA that you are going to schedule. On the Action panel, click Design MA. On the MA Control Script tab, copy the MAScript code to the file. Comment out any existing text, and then add the above MA Script code in its place. Click OK to close the file, and to save your changes.</li></ol> </li> To manually start the script, type the following command line at a command prompt:
 * 1) This section is used by the scheduled command script.
 * 2) It sets selected MA attributes and environment variables to ensure
 * 3) changes configured using the Compass client do not override the
 * 4) intended behaviour of the scheduled MA runs.
 * 1) Main section of the control script

c:\zoomserv\data\ds\00000002\My_Batch_File.bat weekend

Note: To start in Full mode, use the Weekend parameter, and to start in Delta mode, use the Weekday parameter. Or, to completely automate the process, schedule the batch file to run at certain intervals.</li></ol>

Additional query words: mms metadirectory zoomit

Keywords: kbhowto kbenv KB297884

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.