Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to capture execution status : success/failure/warning of powershell script when it is called from c#

$
0
0

hi,

i'm writing a small tool to collect detail from office 365 using powershell in c#.

challenge i'm facing is, after the powershell command run, I want to know whether it was successful or not. If not , what was the warning or error.

"if  errors.Count > 0" will help me to understand that it failed and "if  errors.Count == 0" will tell me that there was an issue.

the concern is, I need to clear the error, before running every command to use the above logic to find the success or failure of recent command, is there any other better method do we have? if any , can you please share it.

secondly how to find/capture the warning?

thank you in advance.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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