【问题标题】:exchange powershell list sendas, send on behalf of, AND fullaccess for a given mailbox交换 powershell 列表发送为、代表发送和给定邮箱的完全访问权限
【发布时间】:2018-03-18 11:45:51
【问题描述】:

对于给定的邮箱,我想列出所有拥有任何以下权限的用户:

  • 发送为
  • 代发
  • 完全访问权限

我还没有找到一种简单的方法来一次获得所有 3 个,所以我一直在按权限进行...

get-exolmailbox -identity "example@example.com" | get-exolmailboxpermission | where { ($_.AccessRights -eq "FullAccess") -and ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") }

get-exolmailbox -Identity "example@example.com" | Get-ADPermission | ? { ($_.ExtendedRights -like "*send*") -or ($_.ExtendedRights -like "*full*") -and -not ($_.User -like "*\self*") } | FT -auto User,ExtendedRights

get-exolmailbox -identity "example@example.com" | fl displayname, grantsendonbehalfto

在我花一些时间弄清楚如何按照我想要的方式格式化结果之前,有没有更优雅的方法来获取相同的信息?

我希望最终得到一个 excel 文件,该文件按显示名称列出每个用户以及他们对邮箱拥有哪些权限。

【问题讨论】:

    标签: powershell exchange-server


    【解决方案1】:

    这样的事情应该做你想做的事,它创建一个自定义对象并将你的命令中的信息分配给它的属性。

    $emailaddress = "user1@example.com","user2@example.com"
    
    $MailboxPermissions = @()
    
    foreach ($email in $emailaddress)
    {
        $exolmailbox = get-exolmailbox -identity $email
    
        $FullAccess = $exolmailbox | where { ($_.AccessRights -eq "FullAccess") -and ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") }
        $SendAs = $exolmailbox | Get-ADPermission | ? { ($_.ExtendedRights -like "*send*") -or ($_.ExtendedRights -like "*full*") -and -not ($_.User -like "*\self*") }
    
        $MailboxInfo = New-Object System.Object
    
        $MailboxInfo | Add-Member -type NoteProperty -name DisplayName -value $exolmailbox.displayname
        $MailboxInfo | Add-Member -type NoteProperty -name FullAccess -value $FullAccess
        $MailboxInfo | Add-Member -type NoteProperty -name SendAsUser -value $SendAs.User
        $MailboxInfo | Add-Member -type NoteProperty -name SendAsExtendedRights -value $SendAs.ExtendedRights
        $MailboxInfo | Add-Member -type NoteProperty -name GrantSendOnBehalfTo -value $exolmailbox.grantsendonbehalfto
    
        $MailboxPermissions += $MailboxInfo
    }
    
    $MailboxPermissions 
    

    注意:我无法对此进行测试,因为我在网上找不到任何引用 get-exolmailbox 的内容,而且我之前只见过/使用过 get-mailbox

    【讨论】:

    • 我应该早点提到,对不起。我的 powershell 会话连接到本地交换服务器和交换在线环境。 “exol”部分只是您可以分配的前缀,因此系统知道您正在向哪个环境发出命令。我们使用 exol 作为在线交换的缩写...
    猜你喜欢
    • 2021-02-15
    • 2015-05-12
    • 2011-01-01
    • 2019-02-08
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    相关资源
    最近更新 更多