I'm running a Python script in PowerShell, and I want to send success or failure output to email.
Python example:
import os
print "Running Python script ..."
raise Exception("This Error is coming from Python")
And PowerShell main script:
---some line of code--
$output = python runThisScript.py
Write-Host $output
--- write email---
This works for success case. I get output as success and email is sent. But in case of failure, I just get blank email.
Output in case of failure is something like below:
Running Python script ...
Traceback (most recent call last):
File "runThisScript.py", line 5, in <module>
raise Exception("This Error is coming from Python")
Exception: This Error is coming from Python
I would like to get above trace back statements in email. I am not sure how to capture. Thank you in advance for your comments.