Bulk Mailbox creation with custom SMTP address & setting forwarder

Hi Experts,

I need to create bulk user and mailbox and also need to set forwarding address for that mailbox to contact object (Forward to) option.

I am able to create bulk AD user following the below script and also able to create mailbox following the mailbox creation script.

But I need to set custom SMTP address for those mailbox for that is there any way I can define in the mailbox creation script to add custom SMTP address?

Once the users mailbox will be created, Is there any way I can set forwarding address to a contact object of that user via power shell.

In my case, I just need to create mailbox for the internal domain and set to forwarder to the users contact object.    



Creating Active Directory user:

Import-csv C:\BulkADUsers.csv | % {New-ADUser -Name $_.Name -SamAccountName $_.SamAccountName -Description

$_.Description -Department $_.Department -Path $_.Path -Enabled $True -AccountPassword (ConvertTo-SecureString

$_.Password -AsPlainText -force)}

CSV Format for AD user:

Name              SamAccountName Description      Department      Path                  Enabled      Password
Test, User      Test            Test User       IT           OU=Test,DC=Test,DC=COM     $True   Pass3434@



Creating mailbox

Import-Csv .\BulkADUsersDB.csv  | % {Enable-Mailbox -Identity $_.SamAccountName -Database $_.Database -Alias $_.SamAccountName}

CSV Format for mailbox user:

Name              SamAccountName Description      Department      Path                Database      Enabled      Password
Test, User      Test            Test User       IT           OU=Testing,DC=Test,DC=COM  MDB01            $True   Pass3434@


By following the above script I am able to create user and mailbox but user mailbox is taking default  email address but I need to define custom SMTP address via power shell.

Also once users mailbox will be created, I need to set forwarding address for each users to each contact object via PowerShell..On this note, All contact object already exist in our internal domain.
ipsec600Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

FOXActive Directory/Exchange EngineerCommented:
On your .csv file, the column that has the email addresses name Mailbox and create another column and name it NewEmailAddress

then run the below

Import-CSV "pathtoyour.csv" | ForEach {Set-Mailbox $_.Mailbox -EmailAddresses @{add=$_.NewEmailAddress}}


For the forwarding you can run this command

Import-CSV "pathtoyour.csv" | ForEach {Set-Mailbox -Identity $._Mailbox -DeliverToMailboxAndForward $true -ForwardingSMTPAddress "themailaddress.com"}

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
FOXActive Directory/Exchange EngineerCommented:
You will have to run those commands in the exchange shell
ipsec600Author Commented:
Excellent! thank you  Foxluv.
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
Powershell

From novice to tech pro — start learning today.