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
Jerry SeinfieldAsked:
Who is Participating?

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

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.

AmitIT ArchitectCommented:
Get-Mailbox | Remove-MailboxPermission -User domain\username -AccessRights FullAccess -InheritanceType All
Will SzymkowskiSenior Solution ArchitectCommented:
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

Jerry SeinfieldAuthor Commented:
can you please elaborate on the text file, attach an example please
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

AmitIT ArchitectCommented:
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.
Will SzymkowskiSenior Solution ArchitectCommented:
Amit, based on your script it is not what the user was asking for. The Get-Mailbox command will only get limited mailboxes because you did not use the "ResultSIze unlimited". Also the user is looking to do this for multiple users, so in my script I am referencing a variable.

Feb, I have attached the file.

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
AmitIT ArchitectCommented:
Ya, you are right. However there are only 2 users.
John SalleSenior IT Systems EngineerCommented:
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.
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.