projector1 Posted May 26, 2012 Posted May 26, 2012 With nothing better to do on a sunny saturday afternoon i am trying to knock a script that will examine a robocopy text file (used for mirroring data) and dump the summary into a seperate log file which i will use blat to email me. this is what i have knocked up so far REM this batch file will sync srv11 H:\common data to srv5 H:\common2 Set logfile=E:\logs\commonMIR1.log Set logfile2=E:\logs\commonMIR2.txt Echo Started %date%,%time% >>%logfile% Echo ----------------------------------- >>%logfile% Echo mirroring common directory on SRV11 to SRV5 common2 >>%logfile% Echo. >>%logfile% robocopy "x:\COMMON" "y:\COMMON2" /MIR /ZB /W:0 /A /LOG:E:\logs\COMMONmir2.TXT Echo ----------------------------------- >>%logfile% Echo Finished %date%,%time% >>%logfile% Echo ----------------------------------- >>%logfile% Echo RESULT OF ROBOCOPY COMMON FOLDER MIRROR SCRIPT >>%logfile% type %logfile2% >>%logfile% it works well however the whole contents of the robocopy log appear in the commonMIR1.log. thanks
Arthur Posted May 26, 2012 Posted May 26, 2012 You could use PowerShell to read the last 14 lines of your log file... Get-Content .\CommonMIR1.log | Select-Object -Last 14 ... and send it via e-mail with the Send-MailMessage cmdlet?
projector1 Posted May 26, 2012 Author Posted May 26, 2012 I have not used powershell before, the server i am working on is a 2003 r2 machine. It may be a good time to start, thanks
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now