Powershell module exit with wrong exit code

$LastExitCode is a powershell command which can print the last exit code it produced. Here is my example with it failing;

PS C:> C:\Program Files\ICINGA2\sbin\modules\database_not_available.ps1
FAIL | Check Event Viewer | logentries=1
Error: 50001 Severity: 10 State: 1 The log for database MSSQL$TEST2 is not available

PS C:> $LastExitCode
2

I had seen it referenced in other Icinga work and hoped it would help > PowerShell custom check exits with "OK" if script is not found

For further context, this is OK output;

PS C:> C:\Program Files\ICINGA2\sbin\modules\database_not_available.ps1
OK | logentries=0

PS C:> $LastExitCode
0