Attempting to add users to an Exchange Office 365 group using Add-DistributionGroupMember. The problem is, the error "Couldn't find object" doesn't catch. I've added the -ErrorAction Stop parameter but it is still not catching. What am I missing?
Add-DistributionGroupMember $DLGroupToAddUsers -Member $UserEmail -ErrorAction Stop
$Context.LogMessage("An error occurred when adding the user to $groupName group. Error: " + $_.Exception.Message, "Warning")
so the root issue i've encountered dealing with exchange, these cmdlets all run remotely, so i have not been able to ever catch remote terminating errors, i've had to settle for running my command, and then performing validation that the change was made as my trying to find errors.
its driven me nuts over the years but i've come to accept that limitation