Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

adding an alias to a distribution group in Exchange 2010

Posted on 2011-10-11
15
Medium Priority
?
3,103 Views
Last Modified: 2012-05-28
Hi there

We have one office who has just been moved over to Office 365 for whatever reason.

The users over there require a heavy use of distribution group and due to the nature of their work, we need to often add and remove alias email addresses for the disti groups.

Now, as we all know, Office 365 management is not same as Exchange 2010 management.

The only possible way is using Powershell.

So here is my question.

1. Using Powershell, how do I add an alias to an existing distribution group?

2. When the command is run, it should add another email address as alias and not replace the existing ones as this has happned to me in the past.

Can someone please help? They are losing some important emails due to this reason.

Office 365 support is useless at this.

Exchange admins...help.!!!!
0
Comment
Question by:alex110109
15 Comments
 
LVL 9

Expert Comment

by:chrismerritt
ID: 36951560
I can't comment specifically on O365 as i've never used it. However you can append/remove a single value from a multivalued property (which ProxyAddresses is) by using this I believe:

http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/11/22/Managing-email-addresses-in-exchange-2010.aspx

I've never tried it, but it looks useful. Maybe you could add a test DL and see how it works?

Basic premise is you can quite easily add/remove addresses without having to re-add the whole lot like this:

Set-Mailbox User1 -EmailAddresses @{Add='TestUser1@domain.com’}
0
 
LVL 5

Expert Comment

by:rajkr2020
ID: 36953895

Create a csv file "FileName.csv"

Example:

Name
user1
user2
user3

and then run

Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "GROUP-NAME" -Member $_.Name}
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 36954126
rajkr2020, the question was to add email aliases not members.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 

Author Comment

by:alex110109
ID: 36954874
yes, I need this for a distribution group.

Set-Mailbox command will not work on a distribution group from what I understand.
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 36955758
Of course but you change the command to be the one which is relevant for your object, so you change set-mailbox for set-distributiongroup
0
 
LVL 2

Expert Comment

by:Trefenwyd
ID: 37072331
You should be able to do it with these PowerShell commands:
Set-ExecutionPolicy RemoteSigned

Open in new window


$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange-ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session

Open in new window


Set-DistributionGroup "group1" -EmailAddresses SMTP:group1@domain.com,group1a@domain.com

Open in new window

0
 

Author Comment

by:alex110109
ID: 37076534
Hi Trefenwyd

I know this command already.

However, this is for adding the group for the first time.

But say I have added the group with 5 email address to start with....and then after a month I want to add the 6th one...I have to run this command with all 6 email addresses and not just the new one.
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37076688
alex110109 - did you even attempt my solution?

This contains the method for adding a new email address without having to declare all the others.
0
 

Author Comment

by:alex110109
ID: 37076905
yes my friend I have and if I do this command with just the new address that I want to add...it removes all the other addresses.

Now, the question is..have you tried it?

The only way your solution may work is if MS change the actual commandlet in last 2 months or so...
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37088550
I've used the @Add hash addition against our Exchange 2010 servers to add values to multi valued properties so yes, however as I pointed out in my original reply I can't comment specifically on O365 and what commands work against their systems. If this in not supported with them then you can't use my suggestion, simple as that.

Nowhere did you say my command didn't work though so without knowing that I could only assume it hadn't been tested, based on the information available to me at the time.

The only other thing you can do is bind to the group, retrieve it's list of email addresses, append your own to the list, then set these against it. Thus you should be able to feed a list of additions into a group without knowing what the current addresses are.

If this sounds like something you are interested in I may be able to help.
0
 

Author Comment

by:alex110109
ID: 37093363
Hi Chris

Yes, that sounds like a good work around.

it appears there will be multiple commands which I am happy with as long as I don't have to manually compile the list all over again.

1. assign a variable the value of the list of email addresses.

2. add the value of new email address to the variable

3. run the command to assign the group email address property with the value of updated variable...

I guess that's what the logic will be. I can work out the logic fine at times but not the commands (syntax).

So yes, if you could make up a list of command that do this then I am going to try it.

I do understand your point about O365. although since there is no documentation from MS, even I can't confirm that and we can just assume that.

0
 
LVL 9

Accepted Solution

by:
chrismerritt earned 2000 total points
ID: 37122863
Sorry for the delay in this beeb a busy week for me, but this should do what you want. Essentially we retrieve the current list of email addresses into a collection of data type Microsoft.Exchange.Data.ProxyAddressCollection. Then we loop through a list you feed in which is an array of email addresses, see my example below for the right format. Then finally we remove any duplicates and stamp the DL with the concatenated results.

#Customise Vars
$DLName = "Test DL"
[array]$AddressesToAdd = "smtp:NewEmail1@hippos.local","smtp:NewEmail2@hippos.local","smtp:NewEmail3@hippos.local"

#Get Current Email addresses from DL
[array]$DL = Get-DistributionGroup -Identity $DLName

if ($DL.Count -eq 1)
{
	#Split the current addresses on ","
	$EmailAddresses = $DL[0].EMailAddresses
	
	#Append the new addresses into the array
	foreach ($AddressToAdd in $AddressesToAdd)
	{
		$EmailAddresses += $AddressToAdd
	}
	
	#Get the unique array values
	$EmailAddresses = $EmailAddresses | Select -Unique

	#Add all email addresses to DL
	Set-DistributionGroup -Identity $DL[0] -EmailAddresses $EmailAddresses
}

#Check DL Email Addresses
Get-DistributionGroup -Identity $DL[0] | Select EmailAddresses

Open in new window

0
 

Author Comment

by:alex110109
ID: 37160286
HI

Sorry, I didn't see this update, I will give this a go and let you know.

0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37231570
Any update?
0
 

Author Comment

by:alex110109
ID: 37237219
Hi Chirs

I am talking to Office 365 support for getting the script to run and they are not as knowledgeable as I like them to be so its going through departments after departments.

But I will have to take a call on this as it has been going for a while now.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are literally thousands of Exchange recovery applications out there. So how do you end up picking one that’s ideal for your business & purpose? By carefully scouting the product’s features, the benefits it offers you, & reading ample reviews f…
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question