How do I make an IF statement exit the script with a failed Exit code and show the failed PSADT pop ups?

Hi all,

I currently have the following IF statement in my script and I would like to fail the script if the IF statement is TRUE and show the PSADT failed pop ups come up.

if($presence -eq 'True'){
		"$date - SfB still exists - $filename" | Out-File -FilePath C:\Windows\Logs\SfB_Still_Exists.log -Append
		}else {
		"$date - SfB has been uninstalled successfully" | Out-File -FilePath C:\Windows\Logs\SfB_Uninstalled.log -Append
		}

If I add Exit 1 (or any other number) to any of the branch, it completely exits the whole PSADT script and I don’t get any pop ups.
Any ideas how I can achieve that?

Basically, if the statement is false (or true, doesnt really matter), bring up the failed pops of PSADT.

Thanks in advance,

Hi,
Maybe something like:

if($presence -eq ‘True’){
“$date - SfB still exists - $filename” | Out-File -FilePath “$configToolkitLogDir\SfB_Still_Exists.log” -Append
Show-DialogBox -Title “Failure” -Text “All is wrong” -Buttons OK -Icon Stop
Exit-Script -ExitCode 1603 #orwhateveryouwant
}
else {
“$date - SfB has been uninstalled successfully” | Out-File -FilePath “$configToolkitLogDir\SfB_Uninstalled.log” -Append
}