Aaron

H! I’m Aaron. I keep things here that I want to remember or that I think you might find useful.

Get-MSOLUser and try/catch in powershell

Get-MSOLuser

If you’re depending on try/catch to see if a Microsoft Online user exists, you have to use -ErrorAction Stop. If you don’t do this, Get-MSOLUser will return a non-terminating error and the catch block will not fire.