AaronEG

4 June 2018

Get-MSOLUser and try/catch in powershell

by aaroneg

Summary

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.

tags: rage - powershell - microsoft - MSOnline

This site is open source. Improve this page