[英]How to get a list of all the Shared Mailboxes that a user have access to Exchange2010 | Exchange Management Shell or PowerShell?
Get-Mailbox | 获取邮箱| Get-MailboxPermission -user Get-MailboxPermission-用户
Get-Mailbox | 获取邮箱| Get-MailboxPermission -user | Get-MailboxPermission-用户| Where {$_.AccessRights -like " send as*"} 其中{$ _。AccessRights-类似的“ 发送为*”}
Get-Mailbox | 获取邮箱| Get-ADPermission | Get-ADPermission | Where {$_.extendedRights -like " send-as "} 其中{$ _。extendedRights式的“ 发送为 ”}
All of the above commands does not work for me 以上所有命令均不适用于我
I would do something like this. 我会做这样的事情。 It will output all shared mailboxes and the users that have access to it. 它将输出所有共享邮箱和有权访问它的用户。 For each user it displays the accessrights to the mailbox. 对于每个用户,它显示对邮箱的访问权限。 Depending on the number of users and shared mailboxes, it might take a while to process. 根据用户和共享邮箱的数量,可能需要一段时间才能处理。
(Because of the [ordered]
, you need Powershell version 3 or better. To use it in Powershell 2, remove the [ordered]
. The order in wich the properties will be displayed is not guaranteed then.) (由于[ordered]
,您需要Powershell版本3或更高版本。要在Powershell 2中使用它,请删除[ordered]
。然后将不保证显示属性的顺序。)
function Get-AllMailboxPermissions {
$allMailboxes = Get-Mailbox -ResultSize Unlimited | Sort-Object Identity
if ($allMailboxes.Count -eq 0) {
Write-Warning "No mailboxes found."
return
}
foreach ($box in $allMailboxes) {
$perms = $box | Get-MailboxPermission |
Where-Object { $_.IsInherited -eq $false -and $_.User.ToString() -ne "NT AUTHORITY\SELF" -and $_.User.ToString() -notmatch '^S-1-' } |
Sort-Object User
foreach ($prm in $perms) {
$user = Get-Recipient -Identity $($prm.User.ToString()) -ErrorAction SilentlyContinue
# skip inactive (deleted) users
if ($user -and $user.DisplayName) {
$props = [ordered]@{
"Mailbox" = "$($box.Identity)"
"User" = $user.DisplayName
"AccessRights" = "$($prm.AccessRights -join ', ')"
}
New-Object PsObject -Property $props
}
}
}
}
You would probably want to save this information in a csv file. 您可能希望将此信息保存在一个csv文件中。 In that case call the function like this: 在这种情况下,请调用以下函数:
Get-AllMailboxPermissions | Export-Csv -Path '<PATH-TO-OUTPUT.CSV>' -NoTypeInformation -Encoding UTF8 -Force
Tip: If you want to be able to open the csv in Excel by double-clicking it on the same machine, the Export-Csv
cmdlet has a very useful switch -UseCulture
. 提示:如果希望能够通过在同一台计算机上双击来在Excel中打开csv,则Export-Csv
cmdlet具有一个非常有用的开关-UseCulture
。 With this, the delimiter in the csv file will be the same Excel expects. 这样,csv文件中的定界符将与Excel期望的相同。
I finally got it working with this script below, Run this script in Microsoft Exchange Management Shell make sure that execution policy is all granted before running the script in Management Shell 我终于在下面的脚本中使用了它,在Microsoft Exchange命令行管理程序中运行此脚本,请确保在运行命令行管理程序中的脚本之前已全部授予执行策略
Get-Mailbox | 获取邮箱| Get-MailboxPermission -user $user | Get-MailboxPermission -user $ user | Where {($ .AccessRights -eq "FullAccess") -and -not ($ .User -eq "NT AUTHORITY\\SELF")} | 其中{($ .AccessRights -eq“ FullAccess”)-和 -not ($ .User -eq“ NT AUTHORITY \\ SELF”)} | Format-Table Identity,User 格式表身份,用户
Get-Mailbox | 获取邮箱| Get-ADPermission -user $user | Get-ADPermission -user $ user | Where {($ .ExtendedRights -eq "*send-as*") -and -not ($ .User -eq "NT AUTHORITY\\SELF")} | 其中{($ .ExtendedRights -eq“ * send-as *”)-和 -not ($ .User -eq“ NT AUTHORITY \\ SELF”)} | Format-Table Identity,User 格式表身份,用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.