我试图弄清楚如何做这类事情,但使用PowerShell调用(来自C#)。我们将迁移到Exchange2010,我的旧代码不想工作,因此出现了PowerShell。
IExchangeMailbox exMb = (IExchangeMailbox)userDe.NativeObject;
IADsSecurityDescriptor securityDescriptor = (IADsSecurityDescriptor)exMb.MailboxRights;
IADsAccessControlList acl = (IADsAccessControlList)securityDescriptor.DiscretionaryAcl;
AccessControlEntry ace = new AccessControlEntry();
...
...我的邮箱可以用:
using (PowerShell powershell = PowerShell.Create())
{
powershell.AddCommand("Get-Mailbox");
powershell.AddParameter("Identity", username);
runspace.Open();
powershell.Runspace = runspace;
return powershell.Invoke()[0];
}但是,如果我将结果传递给类似的方法来获得ACL,那么我就可以开始修改它了,如下所示
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,但是文档中说它甚至没有返回类型,所以它以后不会给我一个对象来操作。
请帮帮忙
发布于 2011-12-05 12:47:53
终于弄明白了:
powershell.AddCommand("Add-MailboxPermission");
powershell.AddParameter("Identity", mailboxIdentity);
powershell.AddParameter("User", groupName);
powershell.AddParameter("AccessRights", "FullAccess");
powershell.AddParameter("InheritanceType", "All"); https://stackoverflow.com/questions/8360129
复制相似问题