Script Help Needed for Mailbox Automation - Ex2016 Hybrid

Ramki 816 Reputation points
2021-08-03T03:59:48.01+00:00

Hello Techies.

in my environments, i have created two script to enable the mailboxes on both exchange on-prem servers and off365 mailboxes (Remote Mailboxes) . It is running in schedule task for every one hour

Below are the sample for on-prem

Get-User -OrganizationalUnit E2K16MBX | Where-Object {$.recipientType -eq "user" -and $.Company -eq "cloudnine"} | Enable-Mailbox -Database "DB01EX01"

Below are the sample to create remote Mailbox

$Users = Get-User -OrganizationalUnit Off365mbx | Where-Object {$.recipientType -eq "user" -and $.WindowsEmailAddress -like "$null" }
$users | % {Enable-RemoteMailbox -Identity $_ -RemoteRoutingAddress((($_.UserPrincipalName.split("@")[0])) +"@CloudNine .mail.onmicrosoft.com")}

i would like to create a single script to enable or to function the above needs. also there are scenario's where application mailboxes should not be create any type mailboxes either on-prem servers or Off365 mailboxes

meaning some exception to create any mailboxes in the OU's

could some help me on this

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
999 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,578 questions
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,669 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
2,136 questions
0 comments No comments
{count} votes

Accepted answer
  1. KyleXu-MSFT 26,266 Reputation points
    2021-08-04T01:44:38.273+00:00

    @Ramki

    i would like to create a single script to enable or to function the above needs.

    You could put them into one script directly, they will be run in order. Such as:

    Get-User -OrganizationalUnit E2K16MBX | Where-Object {$.recipientType -eq "user" -and $.Company -eq "cloudnine"} | Enable-Mailbox -Database "DB01EX01"            
    $Users = Get-User -OrganizationalUnit Off365mbx | Where-Object {$.recipientType -eq "user" -and $.WindowsEmailAddress -like "$null" }  
    $users | % {Enable-RemoteMailbox -Identity $ -RemoteRoutingAddress((($.UserPrincipalName.split("@")[0])) +"@cloudnine.mail.onmicrosoft.com")}  
    

    also there are scenario's where application mailboxes should not be create any type mailboxes either on-prem servers or Off365 mailboxes

    About this one, you could set a value for those application mailboxes, such as set the value of Department as "Application", then you will could use this value to exclude these mailboxes:

    Get-User -OrganizationalUnit ToOnline | Where-Object {$_.recipientType -eq "user" -and $_.Department -ne "Application"}  
    

    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.


1 additional answer

Sort by: Most helpful
  1. Saithya 1 Reputation point
    2023-01-20T13:44:42.82+00:00

    @KyleXu-MSFT

    hi, Can you amend this script as it should send us report with successfully enabled remote mailbox.

    Also, it should send report with errors?

    Regards,

    Sai

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.