PowerTip: Return a status code to Linux from PowerShell

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’
Exist 76

The Doctor

Comments (1)

  1. Bewc says:

    I suppose that last line of text should be “Exit 76”, not “Exist 76”.

Skip to main content