我现在正在接触 PowerShell 中的脚本世界,我需要你的帮助来编写一个可能微不足道的小脚本。
我正在尝试使用以下请求制作脚本:
- 通过输入各种邮箱/共享邮箱(用户所在的邮箱)
- 删除用户自动挂载(在这种情况下,它被发现为“test@test.com”。
脚本暂时是这样的:
#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 "test@test.com" | ? {$.AccessRights -like "FullAccess" -and $.IsInherited -eq $false } | remove-mailboxpermission -confirm:$false
Add-MailboxPermission -Identity $Mailbox -User "test@test.com" -AccessRights:FullAccess -AutoMapping $false
}
我想知道这个命令是否可以正常工作,也是因为每次我尝试它都会出现:
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
在此先感谢大家。
亚历克斯