function Test { [CmdletBinding()] #turns into adv function param( [int32] $PingCount ) Test-Connection google.com -Count $PingCount Write-Error -Message "It' a trap" -ErrorAction Stop } try {Test -ErrorAction Stop} catch {Write-Output "Launch problem!" Write-Output $_}