question

Ramki-5805 avatar image
0 Votes"
Ramki-5805 asked KyleXu-MSFT commented

Script Help Needed for Mailbox Automation - Ex2016 Hybrid

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





office-exchange-server-administrationoffice-exchange-online-itprooffice-exchange-hybrid-itprooffice-js-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KyleXu-MSFT avatar image
0 Votes"
KyleXu-MSFT answered KyleXu-MSFT commented

@Ramki-5805

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.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KyleXu-MSFT : Thanks for your update.

Get-User -OrganizationalUnit ToOnline | Where-Object {$.recipientType -eq "user" -and $.Department -ne "Application"} --- How its works? in the same script

say for e.g Appmbx01 and i assingend the departmenet value as "Application" in this scenario , no mailbox shuld be created in exchange server and off365.

0 Votes 0 ·

Such as, when try to find user, it will ignore the user which department is Application:

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

Thanksn @KyleXu-MSFT : Exactly coirrctly. its working ,fantastic.

In real time, anythoer scenarios, weher i could have tested the scripst to create shared mailbox or room mailbox on hybrid

0 Votes 0 ·
Show more comments