2013-06-03 81 views

回答

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(); 
} 
相關問題