Link to home
Start Free TrialLog in
Avatar of Jerry Seinfield
Jerry SeinfieldFlag for United States of America

asked on

script for exchange

Hi Experts,

I need from  your expertise in PowerShell

There are two users I want to permanently remove from all mailboxes as having "full" access.
 
Can we PowerShell something that will remove Them from all mailboxes if they are there? I need to export the results of the command

Exchange version 2013 SP1

Thanks in advance
Avatar of Amit
Amit
Flag of India image

Get-Mailbox | Remove-MailboxPermission -User domain\username -AccessRights FullAccess -InheritanceType All
You can do this via a script. Add your 2 users to a text file, one on each line.
$RMUsers = Get-Content "c:\users.txt"
ForEach ($User in $RMUsers) { 
Get-Mailbox -ResultSize "unlimited" | Remove-MailboxPermissions -User $User -AccessRights -InheritanceType All
}

Open in new window


Will.
Avatar of Jerry Seinfield

ASKER

can you please elaborate on the text file, attach an example please
It is same command, what I gave, Will gave you option to give user in an input file. For whom you want to remove the permission.
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ya, you are right. However there are only 2 users.
Avatar of John Salle
John Salle

With only two users, I think setting up the txt file is a little overkill but a great option if you're talking about more users. With only two users, you can simply re-run Amit's command for the second user. You should , however, add in the ResultSize because we don't know how many total mailboxes we're trying to remove permissions from.

Get-Mailbox -ResultSize Unlimited | Remove-MailboxPermission -User <user email address> -AccessRights FullAccess -InheritanceType All

Open in new window


Where the <user email address> is the user who has the FullAccess permissions to the mailboxes that needs to be removed. You can do domain\user as well, it works interchangeably IIRC.