Exchange 2010 creating Bulk Mailbox and Contacts

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            

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 “”}

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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AVnbmAuthor Commented:
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.
Jian An LimSolutions ArchitectCommented:
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 “” }

note: you need to create enough of information to allow to create a new mailbox

## 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.
AVnbmAuthor Commented:
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??
AVnbmAuthor Commented:
More info... if i break down the command for just the one test user:
set-mailbox -identity jdoe -delivertomailboxandforward $true -forwardingSMTPaddress

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.  

Jian An LimSolutions ArchitectCommented:

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.