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

Powershell exit codes

$
0
0

Hey All,

i am using a software to run powershell scripts.

what i need is to get two possible error codes from Powershell: 0 - there was some error, any error, while running the script.

1 - the script has run succesfully with no errors.

 

accomplishing this via vbscript was easy.

i simply finished every script with an exit code of 1, if the script got to that line - it means that there were no errors.

but powershell, not like vbscript, continues to execute can the code even if there are errors (as far as i know).

is there a command\line i can use to make powershell exit automatically if it encounters an error during execution?

or any other solution you can think of for my problem?

Thank you.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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