【问题标题】:Remove all user accessrights from mailbox in exchange using powershell使用powershell从邮箱中删除所有用户访问权限作为交换
【发布时间】:2013-08-16 03:26:52
【问题描述】:

这会从某个用户的邮箱中删除所有 FullAccess 访问权限。

Remove-MailboxPermission -identity MyMailbox -user SomeUser -AccessRights FullAccess

这将删除 SendAs 访问权限

Remove-MailboxPermission -identity MyMailbox -user SomeUser -AccessRights SendAs

我可以做些什么来一次性删除所有访问权限,这样我就不必明确地删除每一种访问权限?

【问题讨论】:

    标签: powershell exchange-server exchange-server-2010


    【解决方案1】:

    试试这个:

    Remove-MailboxPermission -Identity MyMailbox -User SomeUser -AccessRights FullAccess -InheritanceType All
    

    或(未测试)

    $ar = "FullAccess", "SendAs", "ExternalAccount", "DeleteItem", "ReadPermission", "ChangePermission", "ChangeOwner"
    Remove-MailboxPermission -Identity MyMailbox -User SomeUser -AccessRights $ar -InheritanceType All
    

    【讨论】:

    • 我可以确认这确实有效,我以前也这样做过。您可以通过将要删除的权限列表直接放在参数中来跳过变量和引号:Remove-MailboxPermission -Identity MyMailbox -User SomeUser -AccessRights FullAccess, SendAs,ExternalAccount,DeleteItem,ReadPermission,ChangePermission,ChangeOwner -InheritanceType All
    【解决方案2】:

    删除-MailboxPermission -Identity hppo.us@something.com -User vcx@something.com -AccessRights FullAccess -Confirm: $false

    Remove-RecipientPermission hr-stuttgart@something.com -AccessRights SendAs -Trustee Paul.Rumiz@something.com -confirm: $false

    【讨论】:

    • OP 说他想删除邮箱的所有权限而不对每个权限使用单独的命令。他已经知道如何使用单独的命令来做到这一点。
    【解决方案3】:

    这是我最终得到的结果:

    (假设输入 $alias 为 samaccountname/identity)

    Get-MailboxPermission -Identity $alias | ForEach-Object {Remove-MailboxPermission -identity $_.Identity -user $_.User -AccessRights FullAccess -InheritanceType All -confirm: $false}
    Get-MailboxPermission -Identity $alias | ForEach-Object {Remove-MailboxPermission -identity $_.Identity -user $_.User -AccessRights ReadPermission -InheritanceType All -confirm: $false}
    $Permissions = Get-Mailbox -identity $alias | where {($_.Identity -like "*")} | Get-ADPermission | Where-Object { ($_.ExtendedRights -like "*send-as*") -and $_.User -notlike "*AUTHORITY*" }
    if ($Permissions) 
    {
        $Permissions | ForEach-Object{ Remove-ADPermission -identity $_.Identity -user $_.User -ExtendedRights "Send As" -confirm:$false }
    } 
    
    $mb = Get-mailbox -Identity $alias
    $mb.GrantSendOnBehalfTo = "CN=SomeAdminAccount,CN=Users,DC=ourdomain,DC=local"
    
    Set-Mailbox -Identity $alias -GrantSendOnBehalfTo $mb.GrantSendOnBehalfTo
    

    可以做得更优雅一点,但可以很好地完成工作。

    也可以使用远程 powershell,使用管道的“创造性”解决方案通常会失败。

    【讨论】:

      猜你喜欢
      • 2015-09-07
      • 2017-05-05
      • 2011-01-01
      • 1970-01-01
      • 2018-02-01
      • 2018-03-18
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      相关资源
      最近更新 更多