【问题标题】:Remove full access permissions of all disabled users on shared mailboxes with exchange management shell使用 Exchange Management Shell 删除共享邮箱上所有禁用用户的完全访问权限
【发布时间】:2017-05-05 17:53:03
【问题描述】:

我正在寻找一个 powershell 交换脚本来删除所有禁用用户对特定 OU 中所有共享邮箱的完全访问权限。

这是我目前得到的

Remove-MailboxPermission -Identity Sharedmailbox -AccessRights Fullaccess -InheritanceType all -user DisabledUser -Confirm:$false | where {$_.UseraccountControl -like "*accountdisabled*"}

它似乎有效,但我不确定最后一段 het 脚本是否会检查“accountdisabled”

然后我创建了一个变量,因此它只会检查一个特定的 OU

$ou = Get-ADUser -SearchBase "OU=Functional Mailboxes,OU=Generalaccounts,DC=DOMAIN,DC=COM" -Filter * foreach ($user in $ou)

Remove-MailboxPermission -Identity "$ou" -AccessRights Fullaccess -InheritanceType all -Confirm:$false | where {$_.UseraccountControl -like "*accountdisabled*"}

脚本正在检查正确的 OU,但我仍在寻找最后一部分,它将仅自动删除禁用用户的完全访问权限。

谁能给我指路?

【问题讨论】:

    标签: powershell exchange-server exchange-management-shell


    【解决方案1】:

    而不是在删除邮箱权限后尝试筛选禁用用户(这是您的Remove-MailboxPermission ... | Where-Object ... 似乎打算做的 - 除了您编写它的方式,它只检查禁用状态 after 删除权限),尝试选择禁用的帐户首先然后只将禁用的帐户传递给Remove-MailboxPermission

    Get-ADUser -SearchBase ... -filter {Enabled -eq $false} | Remove-Mailbox ...

    (将... 替换为适当的SearchBase 或Remove-Mailbox 的参数,使用$_ 作为您要删除其邮箱权限的ADUser 的身份。)

    【讨论】:

      猜你喜欢
      • 2021-02-15
      • 2011-01-01
      • 1970-01-01
      • 2015-09-07
      • 2013-08-16
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      相关资源
      最近更新 更多