Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

PowerShell Script | Remove auto-map for single user on many mailboxes

I am now approaching the world of scripting in PowerShell and I need your help with a little script that might be trivial.

I'm trying to make a script with the following requests:

  • Take via input various Mailbox / Shared Mailbox (in which the user is present)
  • Remove the user auto-mount (in this case it is found as "[email protected]".

The script is this for the moment:

#populate the list with the Mailbox / Shared to be removed
$mailboxList = Get-Content -Path "C:\Temp\Mailboxlist.txt"
$ConfirmPreference = 'none'
foreach($Mailbox in $mailboxlist)
{
 #perform the operation on the current $ mailbox
 Get-mailboxpermission -identity $Mailbox -User "[email protected]" | ? {$.AccessRights -like "FullAccess" -and $.IsInherited -eq $false } | remove-mailboxpermission -confirm:$false
 Add-MailboxPermission -Identity $Mailbox -User "[email protected]" -AccessRights:FullAccess -AutoMapping $false
}

I would like to know if this command could work correctly, also because every time I try it comes out this:

PS C:\Temp> C:\Temp\RemoveAutoMapping.ps1
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties 
do not match any of the parameters that take pipeline input.
 + CategoryInfo : InvalidArgument: (Microsoft.Excha...sentationObject:PSObject) [Remove-MailboxPermission], ParameterBindingException
 + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.Exchange.Management.RecipientTasks.RemoveMailboxPermission
 + PSComputerName : outlook.office365.com

Example Screenshot

Answer*

Draft saved
Draft discarded
Cancel
1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Commented Mar 1, 2022 at 0:13

lang-bash

AltStyle によって変換されたページ (->オリジナル) /