0
如何在Microsoft Exchange 2010中創建新郵箱時使用C#代碼禁用「Exchange ActiveSync」?如何在使用C#創建新郵箱時禁用「Exchange ActiveSync」
如何在Microsoft Exchange 2010中創建新郵箱時使用C#代碼禁用「Exchange ActiveSync」?如何在使用C#創建新郵箱時禁用「Exchange ActiveSync」
您可以執行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();
}