Script repository
The scripts create shared and room mailboxes in on-premises Exchange. To execute the scripts, create a business rule, custom command or scheduled task configured for the User object type.
In the scripts, the $exchangeServer variable specifies the fully-qualified domain name of the Exchange server to use.
Shared mailbox
$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 account 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 mailboxs
Enable-Mailbox -Identity '%distinguishedName%' -DomainController $domainControllerFQDN -Shared
}
finally
{
# Close the remote session and release resources.
Remove-PSSession -Session $session
}Room mailbox
$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 account 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
You must be signed in to comment.