powershell - PostgreSQL and schedule Windows 2012 R2 Schedule -
i have question, last saturday when migrate dc windows 2003 2012r2, migrate ok, can't run ps script on windows 2012r2. change parameter, mail adress etc.
param([string]$emailto = "user@domain.com") psql.exe -h 10.1.1.20 -p 5432 -w -h -f c:\scripts\errors_o_htm_v3.sql' -o 'c:\scripts\errors.html -u script database $file = "c:\scripts\errors.html" $old = get-content $file add-content -path $file -value $old $emailfrom = "sender@domain.com" $subject = "reports" $smtpserver = "smtp.serwer.com" $smtpclient = new-object net.mail.smtpclient($smtpserver, 587) $smtpclient.enablessl = $false $smtpclient.credentials = new-object system.net.networkcredential("user","password"); $msg = new-object net.mail.mailmessage $msg.from = $emailfrom $msg.to.add($emailto) $msg.to.add("user@domain.com") $msg.subject = $subject $msg.isbodyhtml = $true $msg.body = $old $msg.bodyencoding = [system.text.encoding]::getencoding("utf-8") $smtpclient.send($msg)
when run script manualy, generate error file , send it, when want set in scheduler - send empty mail, wrong psql.exe -h ...... add psql path environment variables.
in scheduler set: program/script powershell.exe or full path
add arguments c:\scripts\script.ps1, , add -f before path.
but when run script don't generate error file data. thing wrong shedule parameters.
Comments
Post a Comment