Powershell error handling: do something if NO error occured

powershelltry-catch

I've been searching around for this but can't seem to find it.
I'm having a script with a try {} catch {} statement. I'd like to add an action if NO error occured.

Eg

try { something }
catch { "Error occured" }
if (!error) {
"No Error Occured"
}

How can I test if no error occured in the statement?

Thanks in advance

Walter

Best Solution

Check the automatic-variable $error after you cleared it.

$error.clear()
try { something }
catch { "Error occured" }
if (!$error) { "No Error Occured" }