exchange powershell list sendas,代表发送,和给定邮箱的fullaccess

时间:2017-10-06 15:56:52

标签: powershell exchange-server

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

  • 发送为
  • 代表发送
  • 完全访问

我还没有找到一个简单的方法来同时获得所有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文件,该文件按显示名称列出每个用户以及他们对邮箱的权限。

1 个答案:

答案 0 :(得分:0)

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

$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