full mailbox permissions sendas permissions

I was asked to pull user accounts who have the sendas permissions and the full mailbox permissions assigned to users in our organization. At first this appeared to be an easy task but after hours of banging my head against the wall I am not getting the correct results. I have modified and changed these commands below a lot. My output are a few but not all mailboxes. Can someone please help me do the following. I need a script to list users who have full mailbox and sendas permission. I would also like to customize it so that If I wanted to get one user it would work also. This is probably suitable for another script altogether. Any help would be much appreciative.

get-user -Identity "user" | get-mailbox | %{$foo = $_; Get-MailboxPermission $foo | ?{$_.AccessRights -eq "FullAccess" -and $_.IsInherited -eq $false}} | ft {$foo},User,AccessRights

Get-Mailbox | Get-MailboxPermission | Where-Object { ($_.AccessRights -eq "*fullaccess*") -and ($_.User -like "*user*") }
Who is Participating?
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.

Malli BoppeCommented:
try this

get-mailbox -resultsize unlimited | get-mailboxpermission | where { ($_.accessrights -eq "fullaccess") -and ($_.isinherited -eq $false) -and -not ($_.user -like "NT Authority\self")} | ft identity,user -autosize | out-file c:\log\users.txt
techdriveAuthor Commented:
Thanks about to try this now. Do you also have a solution where I can run this for one particuliar user and not all, thanks.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

techdriveAuthor Commented:
Yes this is the same exact command I ran to try to get a single user from this page and this was not pulling all of the mailboxes where full access for mailboxes were applied.

Get-Mailbox | Get-MailboxPermission | Where-Object { ($_.AccessRights -eq "*fullaccess*") -and ($_.User -like "*rajith*") } Please reference my original statement.
Malli BoppeCommented:
Sorry techdrive.Try the below

get-mailbox -identity exchangealias -resultsize unlimited | get-mailboxpermission | where { ($_.accessrights -eq "fullaccess") -and ($_.isinherited -eq $false) -and -not ($_.user -like "NT Authority\self")} | ft identity,user -autosize | out-file c:\log\users.txt

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
techdriveAuthor Commented:
thanks for your help it works like a charm
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

From novice to tech pro — start learning today.