Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Powershell - List users with Full Access Permissions for mailboxes in an OU

$
0
0

Hello All

I am trying to build a report that lists all the mailboxes in an OU and all the users with Full Access Permissions to those mailboxes. We have several mailboxes we use with our phone systems Unified Messaging to receive faxes.

I have most of the script built but I do not understand vectors and variables in Powershell enough to get the output correct. When I run the script the output within the loop displays the names of staff who have access perfectly, but the report output at the end only displays "{Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" for each entry.

Here is the code:

#Starts Powershell Snap-In
############################################################################

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010 -erroraction silentlyContinue
import-module activedirectory

#---------------------------------------------------------------------------

$mailboxes = @(get-mailbox -OrganizationalUnit "ou=Fax E-Mail Boxes,ou=E-mail Only Accounts,ou=Contoso Service Accounts,dc=contoso,dc=com")
$report = @()



foreach ($mailbox in $mailboxes)
{
    $Users = Get-MailboxPermission -identity $mailbox | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | Select User
    $FormattedUsers = $users | select @{Name="User Name";expression={(Get-Recipient $_.user.tostring()).displayname}} | FT
    $FormattedUsers
    $mbObj = New-Object PSObject
    $mbObj | Add-Member -MemberType NoteProperty -Name "Display Name" -Value $mailbox.DisplayName
    $mbObj | Add-Member -MemberType NoteProperty -Name "Users with Access" -Value $FormattedUsers
    $report += $mbObj

}
$report

Thank you in advance for the help


Viewing all articles
Browse latest Browse all 7132


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>