預設沒有這種功能, Exchange 的設計必須先開好信箱, 才可以調整信箱功能.
不過你可以利用 XML 去攔截 Exchange 的「新增使用者」指令, 讓他在正常的指令結束之後, 馬上執行一段 Script (Post-processing) , 修改剛剛新建 User 的信箱功能:
1.先在 EMS 內啟用 Cmdlet Extension Agent:
<pre class="c" name="code">Enable-CmdletExtensionAgent "Scripting Agent"
2.然後在: C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents 這個資料夾底下, 新增一個檔案叫做: ScriptingAgentConfig.xml, 內容則是:
<pre class="c" name="code"><?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="MailboxProvisioning" Cmdlets="enable-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Identity"]).distinguishedName
Set-CASMailbox $user -ActiveSyncEnabled $false
}
</ApiCall>
</Feature>
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Name"]).distinguishedName
Set-CASMailbox $user -ActiveSyncEnabled $false
}
</ApiCall>
</Feature>
<Feature Name="MailboxProvisioning" Cmdlets="enable-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Identity"]).distinguishedName
Set-CASMailbox $user -OWAEnabled $false
}
</ApiCall>
</Feature>
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Name"]).distinguishedName
Set-CASMailbox $user -OWAEnabled $false
}
</ApiCall>
</Feature>
</Configuration>
上面 Script 內的 Cmdlets="new-mailbox" 就是在攔截「新增使用者」這個指令.
至於 Cmdlets="enable-mailbox" 則是萬一你有信箱暫時停用, 要重新 Enable 的時候, 也會被這個指令攔截到, 執行相同的修改.