Setting Unified Groups EmailAddresses Parameter in script

I have a script that is creating unified groups. We use these as ‘forwarders’ after an employee leaves. I have to modify the script to use the -emailaddresses parameter for setting the email addresses.

Here is the scenario:

  • CSV Input
  • Up to 2 email addresses in addition to the primary. Unknown when the csv is input
  • Script is iterating through the ProxyAddresses property in AD to determine if the additional address(es) exist and capture them.
  • Populate PrimarySmtpAddress and either or both of the additional addresses into the EmailAddresses parameter.
I see 2 possibilities here
  1. Create the group with the primary address and then iterate through and add the others as they are found.
  2. Capture all addresses (Primary and additional) into an object and add the object. Not sure this would work though as the object would have empty values if the additional email addresses do not exist and this could error?
 

Looking for suggestions and recommendations for the best way to do this.

 

Please adhere to forum etiquette

https://powershell.org/forums/topic/forum-etiquette-sticky-topic/

I am a bit confused as to what you think is not following etiquette.

I am not asking anyone to write a script for me. I am asking for suggestions on the best way to accomplish one thing in my working PS Module.

I haven’t posted any script so nothing needs to be in Pre tags. I have indicated what the script is already doing and what I need to do and even shown the 2 possibilities that I see.

Can you be more clear as to what you think is a breach of etiquette