This is an earlier piece of code (says 1/21/2007). I don’t do a lot with batch files anymore…however, it looks like this could still work and I thought I’d copy it here.
Purpose: Create Distributed File System (DFS) Replication Health Reports, post them to a web site and send an email notification when complete. This script was designed to run as a scheduled task.
Tested Windows Version(s): Windows 2003 R2
Script language: standard batch file
REM ================================================================================ REM ====================== DFS Replication Report Generation ======================
REM Created by Brian Wuchner on 1/19/2007
REM Optional settings for email notifcation
REM Use the for command to format date and time as YYYY-MM-DD HHMM
for /F "eol=; tokens=1,2,3,4* delims=/, " %%i in ('date /t') do SET YYYYMMDD=%%l-%%j-%%k
for /F "eol=; tokens=1,2,3* delims=:, " %%i in ('time /t') do SET HHMM=%%i%%j%%k
DFSRadmin health new /rgname:%ReplicationGroup% /repname:"%DestinationOutputPath%\%YYYYMMDD%_%HHMM%.html"
if %SendSMTPnotification%==yes %BlatSMTPmailPath% -server %SMTP_Server_Address% -f %SMTP_From_Address% -to %SMTP_To_Address% -subject "DFS Replication Report %YYYYMMDD%_%HHMM%" -body "The DFS Replication Report for replication group %ReplicationGroup% dated %YYYYMMDD%_%HHMM% has completed and is ready for review. You may access the report here: %DestinationWebOutput%/%YYYYMMDD%_%HHMM%.html. This report was sent from %computername% by %userdomain%\%username%."