Powershell command to check output of last executed command

Copper Contributor

Just like in Linux, you can use $? to find the output of last command executed, is there any powershell command that I can use on the command line?

 

I tried $? but it returns True or False.

1 Reply

Hello @Sandeepkv3003,

As far as I know, in Linux  $? returns exit status of the most recently executed foreground pipeline. (Reference).

In PowerShell it does pretty much the same returns True or False depending on whether the last command (cmdlet or native) exited without error or not. (Reference)

 

Not sure what you are trying to accomplish and what your use case is but I suppose this could help you: https://stackoverflow.com/questions/43094708/powershell-exit-status

 

Hope that helps.