Script Repository


Provision shared and room mailboxes

May 31, 2016
2177

To provision a room or shared mailbox in Exchange with the help of Adaxes, you need to create a new user account that will represent the mailbox in AD, and then run one of the below scripts against the new user account to provision the account as a shared or room mailbox in Exchange. For more information on how to automatically run a script once a new user is created, see Run PowerShell Script after Creating a User.

Note: The below scripts can be used to provision shared and room mailboxes in Exchange On-Premises. For scripts that can be used with Exchange Online, see Convert user mailbox to resource mailbox in Exchange Online.

Shared Mailbox

Edit Remove
PowerShell
$exchangeServer = "exchangeserver.domain.com" # TODO: Modify me

# Disable the user
$Context.TargetObject.AccountDisabled = $True
$Context.TargetObject.SetInfo()

# Get the DC that Adaxes uses for the user's domain
$domainName = $Context.GetObjectDomain("%distinguishedName%")
$rootDSE = $Context.BindToObject("Adaxes://$domainName/rootDSE")
$domainControllerFQDN = $rootDSE.Get("dnsHostName")

try
{
    # Connect to Exchange Server
    $session = New-PSSession -connectionURI "http://$exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
    Import-PSSession -session $session

    # Create shared mailbox
    Enable-Mailbox -Identity '%distinguishedName%' -DomainController $domainControllerFQDN -Shared
}
finally
{
    # Close the remote session and release resources
    Remove-PSSession -Session $session
}

Room Mailbox

Edit Remove
PowerShell
$exchangeServer = "exchangeserver.domain.com" # TODO: Modify me

# Disable the user
$Context.TargetObject.AccountDisabled = $True
$Context.TargetObject.SetInfo()

# Get the DC that Adaxes uses for the user's domain
$domainName = $Context.GetObjectDomain("%distinguishedName%")
$rootDSE = $Context.BindToObject("Adaxes://$domainName/rootDSE")
$domainControllerFQDN = $rootDSE.Get("dnsHostName")

try
{
    # Connect to Exchange Server
    $session = New-PSSession -connectionURI "http://$exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
    Import-PSSession -session $session

    # Create room mailbox
    Enable-Mailbox -Identity '%distinguishedName%' -DomainController $domainControllerFQDN -Room
}
finally
{
    # Close the remote session and release resources
    Remove-PSSession -Session $session
}

Comments ( 0 )
No results found.
Leave a comment