• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 871
  • Last Modified:

email result of scheduled task

Hi  all  I've created a task to run repadmin.exe /replsummary. is it possible to email the the result.  Thanks
0
cwstad2
Asked:
cwstad2
  • 3
  • 3
2 Solutions
 
Raheman M. AbdulCommented:
Try this:

$replsummary = invoke-expression { cmd.exe /c repadmin.exe /replsummary }
$Body = $replsummary

$to = "receivername@domain.com"
$from = "sendername@domain.com"
 Send-MailMessage -SmtpServer mail.domain.com -From $from  -To $to -Subject 'repl Summary' -Body $body
0
 
Santosh GuptaCommented:
Hi,

if you are using windows 2008 or 2012 then you can achieve this goal by using the "Task Scheduler".
sch
1. create a task to run "repadmin.exe /replsummary > C:\reports\Replication_report.txt".
2. create another task to send the email with using "Replication_report.txt" file as attachment.
 
Note: every time the task 1 will run it will over write the Replication_report.txt file. After that 2nd task will send it for you.

Hope it will help you.
0
 
cwstad2Author Commented:
hi I can't get the code to work it just opens up the text file
0
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
Santosh GuptaCommented:
Hi,

you mean "repadmin.exe /replsummary > C:\reports\Replication_report.txt" ??
0
 
cwstad2Author Commented:
That was on the powershell.  but I have tried the scheduled task and no output

thanks
0
 
Santosh GuptaCommented:
Hi,

do you have the C:\reports, seems not, then change the output path of file.
 or just use

repadmin.exe /replsummary > Replication_report.txt

create a batch file with above command. once success, put that into scheduler as task one.
0
 
cwstad2Author Commented:
Hi yes i have created the reports folder on C:\ will try the batch tomorrow
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now