Author Posts

January 30, 2018 at 7:42 pm

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?

try
{
Add-DistributionGroupMember $DLGroupToAddUsers -Member $UserEmail -ErrorAction Stop
}
catch
{
$Context.LogMessage("An error occurred when adding the user to $groupName group. Error: " + $_.Exception.Message, "Warning")
}

January 30, 2018 at 8:36 pm

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

January 30, 2018 at 10:52 pm

Quite a few of the commands are working – does anyone have a trick to still trap it if it errors?