# What is Powershell exit code or Powershell return code? **Last Updated On:** 23 Jan 2026 **2 minutes read** Powershell scripts after execution return the status of execution, which is referred to as **"return code"** or **"exit code"**. A successful script execution returns a `0` while an unsuccessful one returns a non-zero value that usually can be interpreted as an error code. The last command executed in the function or the script determines the exit status. This document provides steps on how to return error codes on Powershell scripts. ## Steps to return error codes on Powershell scripts: Use the command `Exit $LASTEXITCODE` at the end of the Powershell script to return the error codes from the Powershell script. - **$LASTEXITCODE** holds the last error code in the Powershell script. It is in the form of boolean values, with `0` for success and `1` for failure. - `Exit ` will return custom return codes from the script. ### Example Powershell script for copying a file to a folder: ```powershell $dest ="C:\test" New-Item $dest -type directory -force $source ="C:\samplefile.txt" Copy-Item $source $dest exit $LASTEXITCODE ```