What is the meaning of this line in PowerShell?
I have tried searching on google but I do not see any specific explanations.
What is the meaning of this line in PowerShell?
I have tried searching on google but I do not see any specific explanations.
Classically, programs in MS-DOS and under the Windows Command Line (CMD.EXE) signalled errors by setting the system environment variable ERRORLEVEL
to a non-zero value. PowerShell does not, by default, do this. If one wishes to invoke a PowerShell script, and have it behave like other programs (and batch files) when called from a batch file, the call to [Environment]::Exit()
allows you to set ERRORLEVEL
in a way that is compatible with CMD.EXE's expectations. You can see more about [Environment]::Exit()
at Microsoft Docs.