You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何排除指定Access Rights正确获取MailboxPermission结果?

Hey there, let's break down why your current command isn't filtering out the FullAccess entries and fix it properly.

The Root Cause

The issue here is that the AccessRights property returned by Get-MailboxPermission isn't a single string—it's a collection of MailboxRights enumeration values. When you use $_.AccessRights -ne "FullAccess", you're comparing the entire rights collection to a single string, which doesn't work the way you expect. PowerShell can't infer that you want to exclude any entry that contains FullAccess in its rights set.

Solution 1: Exclude Entries With FullAccess

To filter out any permission entry that includes FullAccess, use the -notcontains operator—it checks if the rights collection does not include the specific FullAccess right:

Get-MailboxPermission -Identity 'CCCC.XXXX.com/Users/test_50' | 
    Where-Object { $_.AccessRights -notcontains "FullAccess" } |
    Select-Object AccessRights

Solution 2: Keep Other Rights, Only Remove FullAccess

If you have entries with multiple rights (like FullAccess + ReadPermission) and you want to retain the non-FullAccess rights instead of discarding the entire entry, you can modify the AccessRights collection directly:

Get-MailboxPermission -Identity 'CCCC.XXXX.com/Users/test_50' |
    ForEach-Object {
        # Remove FullAccess from the rights collection
        $filteredRights = $_.AccessRights | Where-Object { $_ -ne "FullAccess" }
        # Only output the entry if there are remaining rights
        if ($filteredRights.Count -gt 0) {
            $_ | Select-Object *, @{Name='AccessRights'; Expression={$filteredRights}} -ExcludeProperty AccessRights
        }
    } | Select-Object AccessRights

Quick Bonus Tip

If you're seeing inherited permissions cluttering your results, add the -InheritanceType None parameter to Get-MailboxPermission to only retrieve direct permissions assigned to the mailbox.

内容的提问来源于stack exchange,提问作者Ashwin Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:16:35