Remove users from exchange mailbox

I am trying to get this script to remove users with send as and full access permission to a certain mailbox. For some reason this is not working and wanted some assistance please.

$i=Get-content "c:\temp\script.txt"

Foreach-Object {

Remove-MailboxPermission -Identity "mailbox" -User $_. -AccessRights FullAccess -whatif
}

techdriveAsked:
Who is Participating?
 
Chris DentConnect With a Mentor PowerShell DeveloperCommented:
You want a pipe there:
Get-Content "c:\temp\script.txt" | ForEach-Object {
  Remove-MailboxPermission "mailbox" -User $_ -AccessRights FullAccess -WhatIf
}

Open in new window

Otherwise there's no way to get from the file list to the loop.

And I guess you know you want Remove-ADPermission to handle Send As?

Cheers,

Chris
0
 
techdriveAuthor Commented:
Thanks and as usual you are a genuis
0
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.