non-terminating error

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

  • Author
    Posts
  • #37271
    Profile photo of Ian
    Ian
    Participant

    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
    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.