non-terminating error

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

  • Author
    Posts
  • #37271

    Ian
    Participant

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

  • #37272

    Dave Wyatt
    Moderator

    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.