try { # this raises an error Get-Service-Name NonExisting -ErrorAction Stop } catch { # pipe the errorrecord object through the new function # to retrieve all relevant error information # which you then could use to do error logging, or output # custom error messages $_ | ConvertFrom-ErrorRecord