【问题标题】:How can i modify 'mailbox features' on an Exchange user programatically?如何以编程方式修改 Exchange 用户的“邮箱功能”?
【发布时间】:2017-06-30 05:52:56
【问题描述】:

所以我真正需要做的是禁用 Microsoft Exchange 中特定用户的 Webmail 和 ActiveSync“邮箱功能”。我已经研究了它的 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);
        }

但是我不知道如何找到邮箱功能。任何帮助将不胜感激!

【问题讨论】:

    标签: c# exchange-server exchangewebservices


    【解决方案1】:

    您有什么版本的 Exchange?您所说的功能并不是真正的“邮箱功能”,而是传输设置和所有 PowerShell cmdlet 都针对 CAS 服务器运行

    Set-CASMailbox -Identity "John Smith" -OWAEnabled $false;
    Set-CASMailbox -Identity "John Smith" -ActiveSyncEnabled $false;
    

    /叶夫根尼

    【讨论】:

    • 当我尝试在 powershelll 中执行该命令时,我只是一个 set-casmailbox 不是一个可识别的 cmdlet 名称。我不是从交换服务器本身运行它。我们的版本是 2010
    • 它也应该在 Exchange 2010 中工作。您是否运行它 Exchange 命令行管理程序(它是具有预加载 Exchange 功能的 PowerShell 控制台)?如果您在本地计算机上运行 PowerShell cmdlet 并且没有安装 Exchange 管理工具,那么此错误就是由此产生的逻辑后果。因此,您可以直接从 Exchange 服务器安装或运行这些 cmdlet。
    【解决方案2】:

    我在互联网上的某个地方找到了这个,我实际上不记得在哪里。我只是对其进行了修改以达到我的目的。

            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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-05-17
      • 2014-01-27
      • 1970-01-01
      • 2014-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多