Solved

email result of scheduled task

Posted on 2014-03-25
7
778 Views
Last Modified: 2014-03-29
Hi  all  I've created a task to run repadmin.exe /replsummary. is it possible to email the the result.  Thanks
0
Comment
Question by:cwstad2
  • 3
  • 3
7 Comments
 
LVL 18

Accepted Solution

by:
Raheman M. Abdul earned 250 total points
ID: 39952970
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
 
LVL 13

Assisted Solution

by:Santosh Gupta
Santosh Gupta earned 250 total points
ID: 39953682
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
 
LVL 15

Author Comment

by:cwstad2
ID: 39953796
hi I can't get the code to work it just opens up the text file
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39953874
Hi,

you mean "repadmin.exe /replsummary > C:\reports\Replication_report.txt" ??
0
 
LVL 15

Author Comment

by:cwstad2
ID: 39953941
That was on the powershell.  but I have tried the scheduled task and no output

thanks
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39953962
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
 
LVL 15

Author Comment

by:cwstad2
ID: 39954531
Hi yes i have created the reports folder on C:\ will try the batch tomorrow
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now