remove all rights for a specific user on all exchange mailboxes

Is this a statement state of the art?
#Remove permission to all mailboxes for user $strUser
Get-MailboxDataBase | Remove-MailboxPermission -User $strUser -AccessRights FullAccess
#Remove SendOnBehalf of right to all mailboxes for user $strUser
Get-MailboxDatabase | Remove-ADPermission -User $strUser -ExtendedRights "send as"
François VDCIcT service DeskAsked:
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.

Jose Gabriel Ortega CastroCEOCommented:
So what's the question?

 $str = Get-mailbox -identity <Username>
 $ar = "FullAccess", "SendAs", "ExternalAccount", "DeleteItem", "ReadPermission", "ChangePermission", "ChangeOwner"
 Get-mailbox -filter * |ForEach-Object{
    Write-Output "Removing permissions for $($str.SamAccountName) in MBX $($_.SamaccountName)"
    #reference : https://technet.microsoft.com/en-us/library/bb125153%28v=exchg.160%29.aspx?f=255&MSPPError=-2147217396
    Remove-MailboxPermission -identity $_.SamAccountName -User $str.SamAccountNAme -AccessRights $ar -InheritanceType All -confirm:$false
 }

Open in new window


Main source:
https://technet.microsoft.com/es-es/library/bb125153%28v=exchg.160%29.aspx?f=255&MSPPError=-2147217396


Posible errors:
https://social.technet.microsoft.com/Forums/en-US/50a94a45-903e-409e-ba5c-116d84bed7ff/cannt-remove-full-access-rights-for-one-user?forum=exchangesvrdeploylegacy
http://exchange-powershell.com/2010/06/03/exchange-cannot-remove-ace-on-object-because-it-is-not-present
http://clintboessen.blogspot.mx/2015/04/unable-to-remove-mailbox-permission-in.html
http://www.morgantechspace.com/2015/08/powershell-remove-full-access-permissions-from-mailbox.html
0

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
AlanConsultantCommented:
Hi François,

It will depend on how well the environment has been setup and managed.

Hopefully, at no point, have any permissions been granted directly to a user object, only to security groups.

If so, then removing all access from a user is easy - you just pull up which groups they are a member of, and remove the ones that you don't want them to have any more.

If the setup has not been managed this way, you may find that permissions have been granted directly to the user.  In an edge case, the person doing this might have documented everything (not ideal, but okay from a professional perspective), but if not you will need to track down all of those occurrences and remove them one at a time.

If you do have to do this, at the very least, make sure the 'owners' of the environment implement procedures so that the practice stops immediately - it won't help with the past mess, but it will mean it doesn't get any worse.

Alan.
0
François VDCIcT service DeskAuthor Commented:
@Alan ; No, it's not the case. Security has been set to user object. The main reason is the autoload of shared mailbox into Outlook. putting people into group do not work with autoload of sharedmailbox....

@Jose Ortega : question is does the statements will do the job they are supposed to do [REMOVE RIGHT FOR USER $strUser to ALL MAILBOXES AND SUPPRESS SEND ON BEHALF RIGHT FOR $strUser to ALL MAILBOXES AND, is it the best manner to do it.
0
Jose Gabriel Ortega CastroCEOCommented:
It does
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.