Consider the following scenario:
- You run a PowerShell script at a command prompt on a computer that is running Windows 7 or Windows Server 2008 R2.
- You use the exit statement in the PowerShell script to exit the script with a custom error code.
- You run the echo %errorlevel% command at the command prompt to retrieve the error code.