If you like that, you'll love working with PowerShell's exit codes. [1] [2] [3]
[1] https://weblogs.asp.net/soever/returning-an-exit-code-from-a...
[2] https://octopus.com/blog/powershell-exit-codes
[3] https://community.idera.com/database-tools/powershell/powert...