Fetching users mailbox access for entire organization though powershell / script

Hello Friends,

I want to create a script to see all on premise users who have access to shared or user mailboxes in exchange 2010 environment.

For individual access we were thinking:

Get-Mailbox -resultsize "Unlimited" | Get-MailboxPermission | where { ($_.AccessRights -eq "FullAccess") -and ($_.User -like "domain\test") -and ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") } | ft User, @{Name="Identity";expression={($_.Identity -split "/")[-1]}} -Autosize

Can we import-csv with user column with a loop or something similar ?

If yes how exactly, if someone can guide me with it.

I am not good with scripting at all and can really use some help as we need this done soon as possible.

Thanks a ton !!
Nick PerksIT DirectorAsked:
Who is Participating?
$userlist = Import-Csv -Path C:\users.csv

foreach ($user in $userlist) {

$mailbox = get-Mailbox -identity $user -Erroraction SilentlyContinue

if ( $mailbox -ne $null) {

Get-MailboxPermission -Identity $mailbox| where { ($_.AccessRights -eq "FullAccess") -and ($_.User -like "domain\test") -and ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") } | Select Name, @{n="Alias";e={(get-recipient $_.alias}},AccessRights,IsInherited | Export-csv -path c:\output.csv -NTI -Append -Force



Open in new window

Loop your output like below

$Mailboxes = Get-Mailbox -resultsize Unlimited

foreach ($mailbox in $Mailboxes) {

Get-MailboxPermission -Identity $mailbox| where { ($_.AccessRights -eq "FullAccess") -and ($_.User -like "domain\test") -and ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") } | ft User, @{Name="Identity";expression={($_.Identity -split "/")[-1]}} -Autosize


Open in new window

Jose Gabriel Ortega CEE Solution Guide - CEO Faru Bonon ITCommented:
Import-csv .\Csvnamepath.csv | foreach{
    Get-Mailbox $_.Identity | foreach {
        Get-MailboxPermission -Identity $_.alias | where{ $_.User -notmatch 'NT AUTHORITY' } |   select @{Name="AccessRights";Expression={$_.AccessRights -join '`n' }},user,identity,Deny,isInherited,InheritanceType
} | ConvertTo-Csv  # ConvertTo-Html #ConvertTo-Json

Open in new window

Nick PerksIT DirectorAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.