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?
 
Jose Gabriel Ortega CConnect With a Mentor CEO J0rt3g4 Consulting ServicesCommented:
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
 
AlanConnect With a Mentor ConsultantCommented:
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 CCEO J0rt3g4 Consulting ServicesCommented:
It does
1
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.