DFS replication is a great way to synchronize data for DR purposes, but there is no built in scheduled reporting mechanism. Well here is a script I wrote that runs the dfrsadmin reports and attaches each report, as well as sends links to each report for review. Very helpful considering I was logging in each day and running commands to check the backlog. Now, I can just open these reports every day and all the information is right there. Once the script is there, simply create a scheduled task to run this script at whatever time interval is needed to receive these reports.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:: Script to generate and email DFS Replication Health Reports.
:: Dennis Miller
:: November 10 2010
@echo off
set CURRDATE=%TEMP%\CURRDATE.TMP
set CURRTIME=%TEMP%\CURRTIME.TMP
set REPORTS=\\*******\*******
set FROM=”DFS Replication <******@*******>”
set TO=”******* <*******@*******>”
DATE /T > %CURRDATE%
TIME /T > %CURRTIME%
:: This cleans up old reports to conserve space.
FORFILES /p E:\****************** /m *.* /d -30 /c “cmd /c del @FILE”
:: This adds the date and time to the health report name and to the title of the email.
for /F “tokens=1,2,3,4 delims=/, ” %%i in (%CURRDATE%) Do SET DDMMYYYY=%%j-%%k-%%l
for /F “tokens=1,2,3 delims=:, ” %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k
:: Here you define the different resources by specifying the name of each replication group, server name and
:: share name. You can do this for as many replication groups as you want, but keep in mind that the script
:: will wait until all reports complete before mail is sent out.
set RG1_Report=%REPORTS%\folder1-%DDMMYYYY%-%HHMM%.html
set RG2_Report=%REPORTS%\folder2-%DDMMYYYY%-%HHMM%.html
set RG3_Report=%REPORTS%\folder3–%DDMMYYYY%-%HHMM%.html
set RG4_Report=%REPORTS%\folder4-%DDMMYYYY%-%HHMM%.html
:: Here you define the report options as specified in the dfrsadmin.exe utility.
dfsradmin health new /rgname:folder1 /refmemname:server1 /ReportName:%RG1_Report% /fscount:true
dfsradmin health new /rgname:folder2 /refmemname:server1 /ReportName:%RG2_Report% /fscount:true
dfsradmin health new /rgname:folder3 /refmemname:server2 /ReportName:%RG3_Report% /fscount:true
dfsradmin health new /rgname:folder4 /refmemname:server3 /ReportName:%RG4_Report% /fscount:true
:: Here is where the current report file names get stored into this temp file location, overwritten each time.
echo folder1 %RG1_Report% > %TEMP%\healthMessageBodyRG1.txt
echo folder2 %RG2_Report% > %TEMP%\healthMessageBodyRG2.txt
echo folder3 %RG3_Report% > %TEMP%\healthMessageBodyRG3.txt
echo folder4 %RG4_Report% > %TEMP%\healthMessageBodyRG4.txt
:: This is for the links to all of the report file locations to show up in the body of the message.
echo folder1 %RG1_Report% > %TEMP%\healthMessageBody.txt
echo folder2 %RG2_Report% >> %TEMP%\healthMessageBody.txt
echo folder3 %RG3_Report% >> %TEMP%\healthMessageBody.txt
echo folder4 %RG4_Report% >> %TEMP%\healthMessageBody.txt
:: This is for the individual reports to be sent as attachments.
for /F “tokens=2 delims= ” %%i in (%TEMP%\healthMessageBodyRG1.txt) Do SET FILESRG1=%%i
for /F “tokens=2 delims= ” %%i in (%TEMP%\healthMessageBodyRG2.txt) Do SET FILESRG2=%%i
for /F “tokens=2 delims= ” %%i in (%TEMP%\healthMessageBodyRG3.txt) Do SET FILESRG3=%%i
for /F “tokens=2 delims= ” %%i in (%TEMP%\healthMessageBodyRG4.txt) Do SET FILESRG4=%%i
:: Here is the command to email the links as well as the attachments using the sendEmail.exe utility.
sendEmail.exe -f %FROM% -t %TO% -u “DFS Replication Health Reports %DDMMYYYY%” -o message-file=%TEMP%\healthMessageBody.txt -s smtpserver.domain.com -a %FILESRG1% %FILESRG2% %FILESRG3% %FILESRG4%