How to view endstop status on Marlin using G-Code?

On 3D printer mainboards running the Marlin firmware, you can useĀ M119 to view the current state of the endstops. Example output:

M119
Reporting endstop status
x_max: TRIGGERED
y_max: TRIGGERED
z_min: TRIGGERED
ok