首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Powershell设置Exchange邮箱ACL

使用Powershell设置Exchange邮箱ACL
EN

Stack Overflow用户
提问于 2011-12-02 17:21:03
回答 1查看 992关注 0票数 0

我试图弄清楚如何做这类事情,但使用PowerShell调用(来自C#)。我们将迁移到Exchange2010,我的旧代码不想工作,因此出现了PowerShell。

代码语言:javascript
复制
IExchangeMailbox exMb = (IExchangeMailbox)userDe.NativeObject;
IADsSecurityDescriptor securityDescriptor = (IADsSecurityDescriptor)exMb.MailboxRights;
IADsAccessControlList acl = (IADsAccessControlList)securityDescriptor.DiscretionaryAcl;
AccessControlEntry ace = new AccessControlEntry();
...
...

我的邮箱可以用:

代码语言:javascript
复制
        using (PowerShell powershell = PowerShell.Create())
        {
            powershell.AddCommand("Get-Mailbox");
            powershell.AddParameter("Identity", username);

            runspace.Open();
            powershell.Runspace = runspace;
            return powershell.Invoke()[0];
        }

但是,如果我将结果传递给类似的方法来获得ACL,那么我就可以开始修改它了,如下所示

代码语言:javascript
复制
    using (PowerShell powershell = PowerShell.Create())
    {
        powershell.AddCommand("Get-Acl");
        powershell.AddArgument(mailbox);

        runspace.Open();
        powershell.Runspace = runspace;
        return powershell.Invoke()[0];
    }

...I get

术语“Get-Acl”不被识别为cmdlet的名称。

...coming在日志中。我也尝试了'Get-ACL‘,以防它区分大小写,但我认为第一个版本是正确的。

我也尝试了Get-MailboxPermission,但是文档中说它甚至没有返回类型,所以它以后不会给我一个对象来操作。

请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2011-12-05 12:47:53

终于弄明白了:

代码语言:javascript
复制
powershell.AddCommand("Add-MailboxPermission");
powershell.AddParameter("Identity", mailboxIdentity); 
powershell.AddParameter("User", groupName); 
powershell.AddParameter("AccessRights", "FullAccess"); 
powershell.AddParameter("InheritanceType", "All"); 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8360129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档