non-terminating error

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 1 year, 2 months ago.

  • Author
  • #37271
    Profile photo of Ian

    is there a way to log a non-terminating error without forcing the script to stop with '-ErrorAction Stop'

  • #37272
    Profile photo of Dave Wyatt
    Dave Wyatt

    You can use the -ErrorVariable parameter, and check for any records in that variable after the command exits:

    Do-Something -ErrorVariable myErrors
    if ($myErrors)
        # handle errors

You must be logged in to reply to this topic.