Closed Chris4678 closed 5 years ago
Hey @Chris4678 - If you add -ErrorAction Stop
to your Update-GSUser
call, it should trigger a terminating error and catch it appropriately. Let me know if your experience is different!
Hello Scrthq. Thanks for the quick response. I have added that to all of my commands now. Thanks a lot for building this module, its awesome!
@Chris4678 I'm glad you're enjoying it!! <3
I am trying to build some error handling into my code. Normally try and catch statements are very handy for this. However, if you do something like my simple code below it will never actually trigger the catch statement. Is there a work around for this? How should I catch errors?
Try { Update-GSUser -User email@domain.com -OrgUnitPath $InvalidOUPath } catch { "unable to update $user's OU" | Out-File $log -append }