email - I have a working powershell script that hangs sending mail when run with the Task Scheduler -
i have paperless system mileage reimbursement sheets. have had issues people submitting multiple sheets , supervisors check created powershell script sql query , creates text file of supervisors. then, reads list , runs sql query of employees names , date ranges of submitted mileage sheets, saves csv file , emails supervisor can check when approving next set of sheets.
when run script command line works great. want schedule run weekly. when test it, however, hangs. creates first file of supervisors. after doing testing, (i commented out section sends mail) hangs sending first email message. have task scheduled run same credentials used create credentials file. suggestions?
here have send mail
param($user,$file) $user="system_mangler@familyenrichment.cc" $password = get-content "systemmangler.txt" | convertto-securestring $credential = new-object system.management.automation.pscredential($user,$password)
that @ beginning of script. in loop sends mail. testing purposes having send me rather users.
$from = "system_mangler@familyenrichment.cc" $to = "ebosworth@familyenrichment.cc" $attachment = "c:\backup\tools\testing.csv" $subject = "mileage date ranges" $body = "here list of employees , dates of submitted mileage sheets. when approving mileage sheets, please check make sure not duplicate. `r`n thank `r`n system mangler" $smtpserver = "smtp.gmail.com" $smtpport = "587" send-mailmessage -from $from -to $to -subject $subject ` -body $body -smtpserver $smtpserver -usessl -port $smtpport ` -credential $credential -attachments $attachment
Comments
Post a Comment