exit status in windows powershell scripting

You can use below variables to see if the last command was successful or not.
 
$?
$lastExitCode

If the last command was successful, $? will return True. Otherwise it returns False. If the last command was successful, $lastExitCode will have 0 value. Otherwise it has a non zero value. To return an exit code from script, you can use below command.
 
exit <code-value>

Web development and Automation testing

solutions delivered!!