Get-MSOLUser and try/catch in powershell
If you’re depending on try/catch to see if a Microsoft Online user exists, you have to use
-ErrorAction Stop because some idiot thought that a cmdlet that cannot do it’s one job shouldn’t return a terminating error. If you don’t do this, Get-MSOLUser will return a non-terminating error and the catch block will not fire.
This site is open source. Improve this page