Home
%3CLINGO-SUB%20id%3D%22lingo-sub-423234%22%20slang%3D%22en-US%22%3ESample%20script%20for%20automating%20DFS%20Replication%20health%20reports%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-423234%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Jun%2019%2C%202006%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%23%20REM%20This%20script%20needs%20to%20run%20as%20a%20daily%20scheduled%20task%20by%20someone%20who%20has%20%3CBR%20%2F%3E%20%23%23%20REM%20local%20administrator%20rights%20for%20all%20machines%20in%20reported%20RG.%26nbsp%3B%20This%20script%20%3CBR%20%2F%3E%20%23%23%20REM%20will%20generate%20a%20health%20report%20for%20all%20members%20of%20the%20replication%20group%2C%20%3CBR%20%2F%3E%20%23%23%20REM%20with%20backlog%20based%20on%20a%20specified%20reference%20member.%26nbsp%3B%20When%20reports%20are%20%3CBR%20%2F%3E%20%23%23%20REM%20complete%20they%20will%20be%20saved%20to%20a%20specified%20share.%26nbsp%3B%20When%20ALL%20reports%20are%20%3CBR%20%2F%3E%20%23%23%20REM%20done%2C%20mail%20will%20be%20sent%20to%20the%20specified%20e-mail%20alias%20with%20links%20to%20the%20%3CBR%20%2F%3E%20%23%23%20REM%20share.%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%40echo%20off%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20set%20CURRDATE%3D%25TEMP%25CURRDATE.TMP%20%3CBR%20%2F%3E%20set%20CURRTIME%3D%25TEMP%25CURRTIME.TMP%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20DATE%20%2FT%20%26gt%3B%20%25CURRDATE%25%20%3CBR%20%2F%3E%20TIME%20%2FT%20%26gt%3B%20%25CURRTIME%25%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%23%20REM%20This%20adds%20the%20date%20and%20time%20to%20the%20health%20report%20name%20and%20to%20the%20title%20%3CBR%20%2F%3E%20%23%23%20REM%20of%20the%20e-mail.%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20set%20PARSEARG%3D%22eol%3D%3B%20tokens%3D1%2C2%2C3%2C4*%20delims%3D%2F%2C%20%22%20%3CBR%20%2F%3E%20for%20%2FF%20%25PARSEARG%25%20%25%25i%20in%20(%25CURRDATE%25)%20Do%20SET%20DDMMYYYY%3D%25%25j-%25%25k-%25%25l%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20set%20PARSEARG%3D%22eol%3D%3B%20tokens%3D1%2C2%2C3*%20delims%3D%3A%2C%20%22%20%3CBR%20%2F%3E%20for%20%2FF%20%25PARSEARG%25%20%25%25i%20in%20(%25CURRTIME%25)%20Do%20Set%20HHMM%3D%25%25i%25%25j%25%25k%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%23%20REM%20Here%20you%20define%20the%20different%20resources%20by%20specifying%20the%20name%20of%20each%20%3CBR%20%2F%3E%20%23%23%20REM%20replication%20group%2C%20server%20name%20and%20share%20name.%26nbsp%3B%20You%20can%20do%20this%20for%20as%20%3CBR%20%2F%3E%20%23%23%20REM%20many%20replication%20groups%20as%20you%20want%2C%20but%20keep%20in%20mind%20that%20the%20script%20%3CBR%20%2F%3E%20%23%23%20REM%20will%20wait%20until%20all%20reports%20complete%20before%20mail%20is%20sent%20out.%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20set%20RG1_Report%3D%5CServer_nameShare_NameRG1_Name-%25DDMMYYYY%25-%25HHMM%25.html%20%3CBR%20%2F%3E%20set%20RG2_Report%3D%5CServer_nameShare_NameRG2_Name-%25DDMMYYYY%25-%25HHMM%25.html%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%40echo%20on%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%23%20REM%20This%20generates%20the%20reports%20with%20Dfsradmin.exe%20(you%20can%20use%20help%20to%20see%20%3CBR%20%2F%3E%20%23%23%20REM%20what%20else%20it%20can%20do.)%26nbsp%3B%20You%20need%20to%20set%20the%20name%20of%20the%20replication%20%3CBR%20%2F%3E%20%23%23%20REM%20group%2C%20the%20name%20of%20the%20reference%20server%20for%20calculating%20backlog%2C%20the%20%3CBR%20%2F%3E%20%23%23%20REM%20domain%20the%20RG%20is%20in%2C%20and%20a%20name%20for%20the%20report.%26nbsp%3B%20The%20time%20and%20date%20%3CBR%20%2F%3E%20%23%23%20REM%20variables%20we%20defined%20earlier%20in%20the%20script%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20dfsradmin%20health%20new%20%2Frgname%3ARG1%20%2Frefmemname%3ADomain_nameServer_Name%20%2Fdomain%3Adomain_name.com%20%2FReportName%3A%25RG1Report%25%20%3CBR%20%2F%3E%20dfsradmin%20health%20new%20%2Frgname%3ARG2%20%2Frefmemname%3ADomain_nameServer_Name%20%2Fdomain%3Adomain_name.com%20%2FReportName%3A%25RG2Report%25%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20echo%20RG1%26nbsp%3B%20%25RG1Report%25%20%26gt%3B%26nbsp%3B%20%25TEMP%25healthMessageBody.txt%20%3CBR%20%2F%3E%20echo%20RG2%26nbsp%3B%20%25RG2Report%25%20%26gt%3B%26gt%3B%20%25TEMP%25healthMessageBody.txt%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%23%23%20REM%20You%20will%20need%20to%20obtain%20an%20email%20command%20line%20application%20for%20this%20%3CBR%20%2F%3E%20%23%23%23%20REM%20next%20part.%26nbsp%3B%20You%20will%20use%20the%20program%20to%20send%20an%20email%20with%20links%20to%20%3CBR%20%2F%3E%20%23%23%23%20REM%20the%20health%20reports%20to%20an%20alias%20of%20your%20choice.%26nbsp%3B%20You%20may%20want%20address%20%3CBR%20%2F%3E%20%23%23%23%20REM%20this%20mail%20to%20a%20distribution%20group.%20%3CBR%20%2F%3E%20%23%23%23%20REM%20%3CBR%20%2F%3E%20%23%23%23%20REM%20The%20command%20below%20is%20an%20example%20of%20how%20to%20send%20the%20mail%20using%20a%20%3CBR%20%2F%3E%20%23%23%23%20REM%20ficticious%20command%20line%20mail%20application.%26nbsp%3B%20You%20will%20need%20to%20reformat%20%3CBR%20%2F%3E%20%23%23%23%20REM%20the%20command%20to%20be%20compatible%20with%20your%20command%20line%20mail%20application.%20%3CBR%20%2F%3E%20%23%23%23%20REM%20%3CBR%20%2F%3E%20%23%23%23%20REM%20You%20many%20need%20to%20give%20the%20sending%20alias%20the%20%22Send%20As%22%20right%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CP%3Ecl_mail.exe%20smtp%20server%3Amy_smtphost%20to%3Asome_Alias%40domain.com%20from%3Ayour_alias%40domain.com%20subject%3A%22DFS%20Replication%20Health%20Reports%20%25DDMMYYYY%25%22%20message%3A%40%25TEMP%25healthMessageBody.txt%20auth%3Asspi%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-423234%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Jun%2019%2C%202006%20%23%23%23%23%23%23%23%23%23%20REM%20This%20script%20needs%20to%20run%20as%20a%20daily%20scheduled%20task%20by%20someone%20who%20has%20%23%23%20REM%20local%20administrator%20rights%20for%20all%20machines%20in%20reported%20RG.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-423234%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Edfs%20replication%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPages%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Not applicable
First published on TECHNET on Jun 19, 2006
#######
## REM This script needs to run as a daily scheduled task by someone who has
## REM local administrator rights for all machines in reported RG.  This script
## REM will generate a health report for all members of the replication group,
## REM with backlog based on a specified reference member.  When reports are
## REM complete they will be saved to a specified share.  When ALL reports are
## REM done, mail will be sent to the specified e-mail alias with links to the
## REM share.
#######

@echo off

set CURRDATE=%TEMP%CURRDATE.TMP
set CURRTIME=%TEMP%CURRTIME.TMP

DATE /T > %CURRDATE%
TIME /T > %CURRTIME%

######
## REM This adds the date and time to the health report name and to the title
## REM of the e-mail.
######

set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
for /F %PARSEARG% %%i in (%CURRDATE%) Do SET DDMMYYYY=%%j-%%k-%%l

set PARSEARG="eol=; tokens=1,2,3* delims=:, "
for /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k

#######
## REM Here you define the different resources by specifying the name of each
## REM replication group, server name and share name.  You can do this for as
## REM many replication groups as you want, but keep in mind that the script
## REM will wait until all reports complete before mail is sent out.
#######

set RG1_Report=\Server_nameShare_NameRG1_Name-%DDMMYYYY%-%HHMM%.html
set RG2_Report=\Server_nameShare_NameRG2_Name-%DDMMYYYY%-%HHMM%.html

@echo on

#######
## REM This generates the reports with Dfsradmin.exe (you can use help to see
## REM what else it can do.)  You need to set the name of the replication
## REM group, the name of the reference server for calculating backlog, the
## REM domain the RG is in, and a name for the report.  The time and date
## REM variables we defined earlier in the script
#######

dfsradmin health new /rgname:RG1 /refmemname:Domain_nameServer_Name /domain:domain_name.com /ReportName:%RG1Report%
dfsradmin health new /rgname:RG2 /refmemname:Domain_nameServer_Name /domain:domain_name.com /ReportName:%RG2Report%

echo RG1  %RG1Report% >  %TEMP%healthMessageBody.txt
echo RG2  %RG2Report% >> %TEMP%healthMessageBody.txt

#######
### REM You will need to obtain an email command line application for this
### REM next part.  You will use the program to send an email with links to
### REM the health reports to an alias of your choice.  You may want address
### REM this mail to a distribution group.
### REM
### REM The command below is an example of how to send the mail using a
### REM ficticious command line mail application.  You will need to reformat
### REM the command to be compatible with your command line mail application.
### REM
### REM You many need to give the sending alias the "Send As" right
#######

cl_mail.exe smtp server:my_smtphost to:some_Alias@domain.com from:your_alias@domain.com subject:"DFS Replication Health Reports %DDMMYYYY%" message:@%TEMP%healthMessageBody.txt auth:sspi