error checking subroutine sometimes doesn't exit.
i've got powershell script runs executable , checks result of executable. executable logs sql server table. ps1 script queries table , supposed exit if returned value doesn't = 120. does, doesn't. *think* might problem logging executable, subroutine *does* send email during failure (value != 120), doesn't exit, causes rest of script try stuff shouldn't.
the other thing couldn't figure out how append value in subject line or body.
i hoping maybe saw obvious i'm missing on exit.
snippet follows
******
$stage_log_status = "0"
$stage_log_status
$msgto = "oncall-at-blay.com"
$msgfrom = "sql1-at-blay.com"
$msgsrvr = "blay-mail"
$msgbody = "please review errolog file!"
$msgsub = "there has been problem on sql1.blay.com!"
$msgatt = "e:\process\logs_stage\dwerrlog_run*.txt"
$msgpri = "high"
send-mailmessage -to $msgto -from $msgfrom -subject $msgsub -body $msgbody -smtpserver $msgsrvr -attachments $msgatt -priority $msgpri
exit
}
no. if did, wouldn't send mail. need debug find out real value you're getting sql. may need convert type.
after line:
$loadctrlstatus = invoke-sqlcmd $loadcntrl
put:
$loadctrlstatus.gettype(), , print out value (write-host) of $loadctrlstatus.overallstatus make sure getting expect.
grant ward, a.k.a. bigteddy
Windows Server > Windows PowerShell
Comments
Post a Comment