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?
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
0
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


Will.
0
Jerry SeinfieldAuthor Commented:
can you please elaborate on the text file, attach an example please
0
What were the top attacks of Q1 2018?

The Threat Lab team analyzes data from WatchGuard’s Firebox Feed, internal and partner threat intelligence, and a research honeynet, to provide insightful analysis about the top threats on the Internet. Check out our Q1 2018 report for smart, practical security advice today!

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.
0
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.
users.txt
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
AmitIT ArchitectCommented:
Ya, you are right. However there are only 2 users.
0
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.
0
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.

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.