[Webinar] Learn how to a build a cloud-first strategyRegister Now


Exchange 2010 creating Bulk Mailbox and Contacts

Posted on 2014-08-28
Medium Priority
Last Modified: 2015-06-17
We have recently acquired a company and they need to start emailing using our corporate email domain.  At this moment we are not ready to ingest their data into our exchange organization.  The new group has 100+ users.  My plan was to create new mailboxes on our exchange 2010 SP1 server and forward the emails to their current email addresses and email system.  They will then set the reply addresses on their email server mailboxes with our corporate email domain.  

Steps include
1) Create external contacts for the new  group in our exchange 2010
2) Set the external contacts to hidden.
3) Create new mailboxes for the new group in our exchange 2010
4) Set forwards on each new mailbox to their external contacts
3) Make the necessary changes on the remote exchange server for the reply from address

I have a CSV file with the contact information.  I am researching creating scripts to the steps above.  I have found individual commands but is there a way to do it in one shot?

the contacttest.CSV file has the following fields:
Name                              Firstname      Lastname      ExternalEmailAddress
John Doe Newcompany      John                       Doe                      John.Doe@Newcompany.co.uk

So far i have step 1 automated and working using the following
Import-Csv “c:\contacttest.csv” | ForEach {New-MailContact -Name $_.Name -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.ExternalEmailAddress -OrganizationalUnit “domain.com/users”}

I try to then use the following script to set all the addresses in the CSV file to hidden:
Import-Csv c:\contacttest.csv | ForEach {Set-MailContact -Name $_.DisplayName -HiddenFromAddressListsEnabled $true}

I get an error:
Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.

If i change $_.DisplayName to $_.Name it moves on but asks for an Identity as follows:
cmdlet Set-MailContact at command pipeline position1
Supply values for the following parameters:

If i type the exact name as its displayed in the name field in the source CSV file (John Doe Newcompany) it works and sets that contact to hidden.

I'll stop there for now.  Any help to get this command to bulk change the newly created contacts to hidden from address book working without prompting for an identity?

Any thoughts or solutions overall to get mailboxes created in bulk and set the forwarding address in one script.

Question by:AVnbm
  • 3
  • 2

Author Comment

ID: 40291124
Update on my own case, i figured out the correct command to hide from address list:
Import-Csv c:\contacttest.csv | ForEach {Set-MailContact -Identity $_.Name -HiddenFromAddressListsEnabled $true}

I now need to bulk create exchange mailboxes and set the auto forward to the above contacts.  Assistance is appreciated.
LVL 37

Expert Comment

by:Jian An Lim
ID: 40292234
okay, i found your question interesting.

the easiest way is you never create contact (waste of object space)
eventually these users will be landed in your environment one way or the other
I will create a user with a mailbox then set the targetaddress to the external address.

Import-Csv “c:\contacttest.csv” | ForEach { New-mailbox -identity $_.Name  -Firstname $_.FirstName -LastName $_.LastName -OrganizationalUnit “domain.com/users” }

note: you need to create enough of information to allow to create a new mailbox
READ http://technet.microsoft.com/en-us/library/aa997663(v=exchg.150).aspx

## this will set the forwarding address
Import-Csv “c:\contacttest.csv” | ForEach { set-mailbox -identity $_.Name -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $_.ExternalEmailAddress }

This will just solve the problem.


Author Comment

ID: 40292443
thanks for your reply... The reason i created contacts is because when you click on a mailbox in the EMC, go to the Mail Flow Settings Tab, choose Delivery Options and choose properties... the Forwarding Addresses section is looking for a contact and you are not able to just specify an SMTP address.   You have to choose and existing contact or mailbox from the list.  Am i missing something??

Since i already created a mailbox for test User John Doe, i am testing out the 2nd part of adding an external address.  I type the command, there is no error it just goes back to a prompt but nothing seems to happen.  I check the Mail Flow Settings Tab/Delivery options for the mailbox and its blank.  I am using the exchange management shell for these commands.

Am i missing something??

Author Comment

ID: 40292864
More info... if i break down the command for just the one test user:
set-mailbox -identity jdoe -delivertomailboxandforward $true -forwardingSMTPaddress john.doe@newcompany.co.uk

again, it seems to work, no errors, but i don't see the forward in the EMC and its also doesn't seem to be forwarding when i send a test email.

If i run the command 'Get-mailbox jdoe | fl'  i see that ForwardingSMTPAddress is set but again, doesn't appear to be working when i send a test.

The command is making the change but its not forwarding email.  Also, not sure i like the fact that it doesn't show up in the EMC.  

As a test i removed the setting via the Shell, waiting a little while, created a contact object and in the EMC under Mail Flow Settings/Delivery options added that contact object for the same external email address.  Once saved mail starts to forward to the external contact right away.

Therefore, the forward setting set via the shell is applied but forwarding is not working.  When you remove the setting and add via the EMC by choosing the contact object it appears to be working correctly.  

LVL 37

Accepted Solution

Jian An Lim earned 1500 total points
ID: 40294463

most of the activities can be achieved via powershell so this is the best way.

one thing i might forget to check is
by default, you are not allow to forward email outside the organisation.
get-remotedomain * | fl autoforwardenabled
whether is true or false (remember it is false by default), you need to change it to true.
set-RemoteDomain * -AutoForwardEnabled:$true

if you insist using your way, i will have to get to a test-lab to try it out .. can't remember how to configure it.

NOte: one way to do so is run the command via EMC and before you hit finish, go to the left bottom corner and get the powershell command that represent what you want to do and work out the bulk method.

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
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

867 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