Script repository

Convert user mailbox to a resource mailbox in Exchange Online

Updated on: Jan 18, 2026, Views: 43438

Exchange

The script converts a Microsoft 365 user mailbox to a room or equipment mailbox in Exchange Online. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.

In the script, the $mailboxType variable specified the type to convert the target mailbox into. Can only be set to Room or Equipment.

$mailboxType = "Room" # TODO: modify me

# Get the object ID in Microsoft 365.
try
{
    $objectId = [Guid]$Context.TargetObject.Get("adm-AzureId")
}
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

You must be signed in to comment.

  • Karbon Homes

    Karbon Homes

    Is there a similar script for on premise please?

  • Andrew

    Andrew

    I see this method uses Basic Authentication. Can you guys start developing Powershell scripts for Modern Authentication?

    • Support

      Support

      Hello Andrew,

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

      • Tim

        Tim

        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?

        • Support

          Support

          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.

  • Ben C

    Ben C

    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

    • Support

      Support

      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.

Got questions?

Support Questions & Answers

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.