November 18th, 2016

PowerTip: Return a status code to Linux from PowerShell

Doctor Scripto
Scripter

Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell.

Hey, Scripting Guy! Question How can I pass a numeric value back to a calling Bash Shell to indicate an error?

Hey, Scripting Guy! Answer Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code is a PowerShell script that returns a value of 76 if the script does not match the value of $Value.

If ($Value -eq ‘Something Good’) { Write-Output ‘It’s Good, it’s very Good’ } Else { Exist 76 }

The Doctor

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.