Script repository
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
Is there a similar script for on premise please?
Support
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.
Andrew
I see this method uses Basic Authentication. Can you guys start developing Powershell scripts for Modern Authentication?
Support
Hello Andrew,
Unfortunately, there is no such possibility as Modern Authentication requires user interaction.
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
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
I was not able to get the Connect to Exchange Online section to work. I changed the connection to the following and it worked:
I also removed the below part of the script as the PS session was not being used:
Remove-PSSession
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.