Never been fond of using Try and Catch. Don´t like it´s not recommended to use in scripts.

Powershell has a built in variable (boolean) that holds if the last command did execute or not ($?).

So inPowershell we test executing something that will nor work. and then check $? to see what happens.

asdfasdf
$?

We see that it returned False, eg the last command did not execute. And if we again do a $? again we see that it returns True, that is because the last command you executed was $? and that did execute.

This also works if you use SilentlyContinue.

$ErrorActionPreference = "SilentlyContinue"
asdfasdf
$?