Author Posts

May 9, 2016 at 2:14 am

Friends

how I can use
get-scheduledtaskinfo
To capture from remote computer and receiving it through mail.

Thanks in Advance.

May 9, 2016 at 4:12 am

Try using a CIM Session to connect to the remote machine with the Get-ScheduledTaskInfo. Collect your info into your email and send it with the Send-MailMessage cmdlet.

May 9, 2016 at 5:27 am

i was after similar the other month, more of a pain than it should be to be honest 🙂

this script was a godsend

https://gallery.technet.microsoft.com/scriptcenter/Get-Scheduled-tasks-from-3a377294

May 9, 2016 at 3:40 pm

It is such a PITA. For a quick start go with the script Mark mentioned above, that is ,if you get it to work without errors.

May 10, 2016 at 1:20 am

Thank You,

yes I am using it. it's working fine.
I want the same output in mail.

.\scheduled-task.ps1 -ComputerName | Where-Object {$_.Name -eq "} | export-csv C:\tst.csv | Send-MailMessage -To -Subject "" -Attachments "C:\tst.csv" -From -SmtpServer

I tried above but getting empty mail.
any suggestion.

May 10, 2016 at 2:18 am

###Get Task Status
$mailcontent = c:\scripts\.\Get-ScheduledTask.ps1 -ComputerName eurevxa01| Where-Object {$_.name -ne 'bginfo' -and $_.userid -eq 'GLOBAL\LDC-KVS.Service' -and $_.lasttaskresult -ne '0'} | Select-Object name, Author, State, Userid, lastruntime, lasttaskresult, nextruntime | Out-String


##Constants
$smtpServer = "smtp.contoso.com"
$From = "EUREVXA01Tasks@contoso.com"
#$Email = "mark.prior@contoso.com"
$Email = "EMEA.IT-Messaging@contoso.com"
$SubjectCPY = "EV Task Status"
$Body = "$mailcontent"

#Email Content
if ($mailcontent) {Send-Mailmessage -smtpServer $smtpServer -from $from -to $Email -subject $subjectCPY -priority High -Body $Body}

the above only fires if $mailcontent is not Null,

Here i am looking for tasks that run as "LDC-KVS.service", that did not complete with a status of "0" and name is not "bginfo"

mail output looks like

—–Original Message—–
From: EUREVXA01Tasks@contoso.com [mailto:EUREVXA01Tasks@contoso.com]
Sent: 10 May 2016 08:00
To: EMEA IT Messaging
Subject: EV Task Status
Importance: High

Name : EV-Clear-State
Author : GLOBAL\ldc-kvs.service
State : Running
UserId : GLOBAL\ldc-kvs.service
LastRunTime : 10/05/2016 07:43:03
LastTaskResult : 267009
NextRunTime : 11/05/2016 06:45:00