DFS Replication Report Task

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 ================================================================================
REM Created by Brian Wuchner on 1/19/2007

SET ReplicationGroup=server1\web_replication\webdev
SET DestinationOutputPath=D:\Inetpub\wwwroot\webdev.domain.alias\ReplicationReport
SET DestinationWebOutput=http://webdev.domain.alias/ReplicationReport
SET SendSMTPnotification=yes

REM Optional settings for email notifcation
SET BlatSMTPmailPath="D:\SCRIPT\BLAT\blat.exe"
SET SMTP_Server_Address=smtp_server.com
SET SMTP_From_Address=scripter@domain.alias
SET SMTP_To_Address=scripter@domain.alias
@ECHO OFF
CLS

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%."
exit

This entry was posted in Scripting. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.