How to create multiple shared mailboxes all with forwarders in 365

GeoffHGC 1 Reputation point
2021-10-01T07:57:45.28+00:00

I am setting up a new customer in 365 and they have literally hundreds of forwarders in place on their existing Cpanel system that I need to bring into the 365 tenant.
To do this, I believe I will need to set up shared mailboxes for each of these addresses then add email forwarding to each one which will be extremely long winded to do manually.

Can anyone help me on how to do this through powershell with a script ? And also how to list and edit them afterwards if necessary.

There are about 400+ that need setting, some forward to internal addresses, some forward to external smtp addresses.

Thanks in advance!

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,373 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xzsssss 8,861 Reputation points Microsoft Vendor
    2021-10-04T08:43:25.28+00:00

    Hi @GeoffHGC ,

    I'm not sure what are you going to do with these shared mailboxes but I do think the users need to have the Full Access permission to use them.

    For your questions, you may use a csv file that include the datas we need like the name of the shared mailbox and the forwarding addresses, and also display name like:
    Name,DisplayName,Internal
    a,a,aaa@keyman .com
    b,b,bbb@keyman .com

    Then:

    $test = import-csv c:/1/1.csv  
          
    Foreach ($data in $test){If((Get-mailbox $data.Name -ErrorAction 'SilentlyContinue') -eq $null){  
    New-Mailbox -Name $data.Name -DisplayName $data.DisplayName -Shared  
    }  
    Set-Mailbox -Identity $data.name -DeliverToMailboxAndForward $True -ForwardingAddress $data.Internal  
    }  
    

    For the external smtp addresses, create another csv like:
    Name,DisplayName,External
    a,a,aaa@keyman .com
    b,b,bbb@keyman .com

    $test = import-csv c:/1/1.csv  
          
    Foreach ($data in $test){If((Get-mailbox $data.Name -ErrorAction 'SilentlyContinue') -eq $null){  
    New-Mailbox -Name $data.Name -DisplayName $data.DisplayName -Shared  
    }  
    Set-Mailbox -Identity $data.name -ForwardingSMTPAddress $data.External  
    }  
    

    The original cmdlet was here: https://learn.microsoft.com/en-us/answers/questions/275036/exchange-online-shared-mailbox-bulk-create.html
    I just changed the last paragraph:)

    Best regards,
    Lou


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.