Hello,
Thank you for the confirmation. Please, find the script below. In the script:
- $exchangeServer – Specifies the host name of the Exchange server to use.
- $parameterName – Specifies the name of the AD object picker parameter used to select the user for search. The parameter name should be specified with the param- prefix.
For information on how to create reports, have a look at the following tutorial: https://www.adaxes.com/tutorials_ActiveDirectoryManagement_CreateReport.htm.
$exchangeServer = "exchangeServer.domain.com"
$parameterName = "param-MyParam"
try
{
$session = New-PSSession -connectionURI "http://$exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
Import-PSSession -session $session -CommandName "Get-Mailbox", "Get-MailboxPermission" -AllowClobber
$mailboxes = Get-mailbox -ResultSize Unlimited
$guidsBytes = New-Object System.Collections.ArrayList
$parameterValue = $Context.GetParameterValue($parameterName)
foreach ($mailbox in $mailboxes)
{
$permissions = $mailbox | Get-MailboxPermission -User $parameterValue | Where{$_.AccessRights -like '*FullAccess*'}
if ($NULL -eq $permissions)
{
continue
}
$guidsBytes.Add($mailbox.Guid.ToByteArray())
}
}
finally
{
if ($session) { Remove-PSSession -Session $session}
}
$searcher = $Context.CreateGuidBasedSearcher($guidsBytes)
$Context.Items.Add($searcher)
For your information, the report generation can take long time depending on the number of mailboxes you have. Unfortunately, there is no way to improve this without limiting the search scope as to obtain the desired it is required to first fetch all existing mailboxes and then check their permissions.