We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Convert user mailbox to a resource mailbox in Exchange Online

The script can be used in business rules, custom commands and scheduled tasks to convert a Microsoft 365 (Office 365) user mailbox to a room or equipment mailbox.

IMPORTANT: The script can be used for cloud mailboxes only, not for remote mailboxes.
Note: For information on how to create resource mailboxes in Exchange On-Premises, see Provision shared and room mailboxes.

Parameter:

  • $mailboxType - Specifies the type of mailbox to convert the target mailbox into.
Edit Remove
PowerShell
$mailboxType = "Room" # TODO: uncomment the type you need
# $mailboxType = "Equipment"

# Get the object ID in Microsoft 365
try
{
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    $Context.LogMessage("The user doesn't have a Microsoft 365 account", "Warning")
    return
}

try
{
    # Connect to Exchange Online
    $Context.CloudServices.ConnectExchangeOnline()
    
    # Change mailbox type
    Set-Mailbox $objectId.ToString() -Type $mailboxType
}
catch
{
    $Context.LogMessage($_.Exception.Message, "Warning")
}
Comments 8
avatar
Karbon Homes Oct 05, 2018
Is there a similar script for on premise please?
avatar
Support Oct 05, 2018
Have a look at the script in the Exchange On-Premises section of the following article in our repository: https://www.adaxes.com/script-repository/connect-to-exchange-with-powershell-s506.htm.
avatar
Andrew Sep 25, 2019
I see this method uses Basic Authentication. Can you guys start developing Powershell scripts for Modern Authentication?
avatar
Support Sep 26, 2019

Hello Andrew,

Unfortunately, there is no such possibility as Modern Authentication requires user interaction. 

avatar
Tim Jan 06, 2020
The Exchange Team has announced that in October 2020 they will be turning off basic authentication for all protocols including remote powershell. Does Adaxes have a plan for this?
avatar
Support Jan 09, 2020

Hello Tim,

Before the October 2020, we will release an update that will use another authentication for communication with Exchange Online. Also, there will be patches issued for older versions.

avatar
Ben C Feb 22, 2021
I was not able to get the Connect to Exchange Online section to work. I changed the connection to the following and it worked:

# Connect to Exchange Online
Connect-ExchangeOnline -Credential $Context.GetOffice365Credential()

I also removed the below part of the script as the PS session was not being used:
Remove-PSSession
avatar
Support Feb 22, 2021
Hello Ben,

The approach you are using is correct for Adaxes 2020.1 and older. Currently, the above script can only be used in Adaxes 2021.1.
Leave a comment
Loading...

Got questions?

Support Questions & Answers