所以我真正需要做的是禁用Webmail和ActiveSync'邮箱功能'对于Microsoft Exchange中的特定用户。我已经查看了PowerShell脚本,但我并不熟悉PS,所以如果可能的话,我宁愿不使用它。
我可以使用ExchangeService和EWS
专门访问服务器和邮件 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.AutodiscoverUrl("user@domain.com");
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox,new ItemView(10));
foreach (Item item in findResults.Items)
{
Console.WriteLine(item.Subject);
}
但是我无法弄清楚如何找到邮箱功能。任何帮助将不胜感激!
答案 0 :(得分:1)
你有什么版本的Exchange?您所谈论的功能并非真正的“邮箱功能”,但传输设置和所有PowerShell cmdlet都针对CAS服务器运行
Set-CASMailbox -Identity "John Smith" -OWAEnabled $false;
Set-CASMailbox -Identity "John Smith" -ActiveSyncEnabled $false;
/卡费尔
答案 1 :(得分:0)
我在互联网的某个地方找到了这个我实在不记得的地方。我只是修改它以达到我的目的。
RunspaceConfiguration runspaceConfig = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfig);
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
string serverFqdn = "server";
pipeline.Commands.AddScript(string.Format("$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://{0}/PowerShell/ -Authentication Kerberos", serverFqdn));
pipeline.Commands.AddScript("Import-PSSession $Session");
pipeline.Commands.AddScript("Set-CASMailbox -Identity '" + userID + "' -OWAEnabled $true");
pipeline.Commands.AddScript("Set-CASMailbox -Identity '" + userID + "' -ActiveSyncEnabled $true");
pipeline.Commands.Add("Out-String");
Collection<PSObject> results = pipeline.Invoke();
runspace.Close();
if (pipeline.Error != null && pipeline.Error.Count > 0)
{
// failed
}
else
{
// Success
}
runspace.Dispose();
pipeline.Dispose();