0
我想弄清楚如何做这种事情,但使用PowerShell调用(从C#)。我们正在转向Exchange 2010,我的旧代码不想工作,因此PowerShell。使用Powershell设置Exchange邮箱ACL
IExchangeMailbox exMb = (IExchangeMailbox)userDe.NativeObject;
IADsSecurityDescriptor securityDescriptor = (IADsSecurityDescriptor)exMb.MailboxRights;
IADsAccessControlList acl = (IADsAccessControlList)securityDescriptor.DiscretionaryAcl;
AccessControlEntry ace = new AccessControlEntry();
...
...
我有使用邮箱OK:
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];
}
...我得到
'获取的ACL' 一词不是REC识别为cmdlet的名称
...出现在日志中。我也尝试过'Get-ACL',以防它是区分大小写的,但我认为第一个版本是正确的。
我也试过Get-MailboxPermission,但文档说它甚至没有返回类型,所以它不会给我一个对象来处理事件。
请帮