How should I disable "Exchange ActiveSync" using C# code while creating a new mailbox in Microsoft Exchange 2010?
Asked
Active
Viewed 453 times
1 Answers
0
You can execute powershell command to disable exchange active sync from c# code.
C# code looks like this:
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();
}

SergeyIL
- 575
- 5
- 11