Adding Multiple Addresses to a Distribution Group

I have a termination script that I run when we are terminating employees. Part of this termination process is to create email forwarding distribution groups where requested. These forwarding groups use the terminated employee’s original email address as the primary smtp.

I have 3 questions about this.

  1. After the mailbox is archived it’s disabled. This is done in a batch and only those mailboxes where the archive completed successfully will be disabled. Occasionally the mailbox does not get disabled but there are no error messages regarding that part of the process. Is there something I can add at this point to tell me that the mailbox disable was not successful? If the mailbox does not get disabled and an email forwarding group is being created it fails because the smtp address is already in use.

  2. I have a sleep built in between the disabling of the mailboxes and the creation of any requested email forwarding groups. Occasionally the email account will be disabled but the group can’t be created because it is still seeing the primary smtp as in use. It is random as to which one might not work. There isn’t any sort of order such as the first one in the list or the last one.

  3. I found out today that I need to be adding an X500 proxy email address to the email forwarding groups as well as the primary smtp address. I know how to do each one individually but am not sure how I can put the 2 together to create them and add them at the same time during the creation of the group. Any help would be greatly appreciated.

  1. I’d modify your script to check for the mailbox disabled state once whatever else is complete.

  2. Again, I think explicitly checking for the disabled status, rather than assuming it, will help you catch these situations and at least report them.

  3. I think you have to add these after the group is created.

Thanks. For #3 I currently set the primary smtp address at the time the group is created as part of the creation process and that works. So I would then need to loop through again, get the current email addresses and add the x500 proxy addresses to that group and then set the mailbox to use all the addresses in the collection. Is that correct?

If you’re creating the group, why not stop and retrieve it right then, update whatever other properties are needed, and then go on to the next mailbox?