Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

error checking subroutine sometimes doesn't exit.

$
0
0

I've got a powershell script that runs an executable and checks the result of that executable.  The executable logs to a sql server table.  The ps1 script queries the table and is supposed to exit if the returned value doesn't = 120.  Sometimes it does, sometimes it doesn't.  I *think* it might be a problem with the logging from the executable, but the subroutine *does* send an email during a failure (value != 120), it just doesn't exit, which causes the rest of the script to try stuff it shouldn't.  

The other thing I couldn't figure out was how to append the value in the subject line or body.

I was hoping maybe someone saw something obvious that I'm missing on the 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 the errolog file!"

$msgsub = "There has been a 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

}


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>