0

在 Microsoft Exchange 2010 中创建新邮箱时,我应该如何使用 C# 代码禁用“Exchange ActiveSync”?

4

1 回答 1

0

您可以执行 powershell 命令以禁用 c# 代码中的交换主动同步。

C# 代码如下所示:

var command = "Get-Mailbox \"name\" | Set-CASMailbox -ActiveSyncEnabled $false";

var runspaceConfig = RunspaceConfiguration.Create();

PSSnapInException snapInException = null;
runspaceConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010", out snapInException);

using (var runspace = RunspaceFactory.CreateRunspace(runspaceConfig))
{
    runspace.Open();

    using (var pipeline = runspace.CreatePipeline())
    {
        pipeline.Commands.AddScript(command);

        var results = pipeline.Invoke();
        // You can handle results here
    }

    runspace.Close();
}
于 2013-07-13T11:41:46.650 回答