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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaheshArchitectCommented:
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

0
MaheshArchitectCommented:
$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

2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose Gabriel Ortega CastroCEOCommented:
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

2
Nick PerksIT DirectorAuthor Commented:
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.