【发布时间】:2022-03-01 08:14:41
【问题描述】:
我现在正在接触 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
提前感谢大家。
亚历克斯
【问题讨论】:
-
您似乎无法将
Get-mailboxpermission输出作为管道输入传递给remove-mailboxpermission。见docs.microsoft.com/en-us/powershell/module/exchange/… 和docs.microsoft.com/en-us/exchange/client-developer/management/…
标签: azure powershell exchange-server script automount