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.
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")
}
Hello Andrew,
Unfortunately, there is no such possibility as Modern Authentication requires user interaction.
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.
# 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
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.