我们正在运行 Exchange 2013,并尝试遵循 Microsoft 的示例 3使用 Exchange 命令行管理程序对公用文件夹进行电子数据展示搜索:
New-MailboxSearch -Name "Contoso Litigation" -AllSourceMailboxes $true -AllPublicFolderSources $true -SearchQuery '"price list" AND "contoso"' -StartDate "01/01/2015" -TargetMailbox "Discovery Search Mailbox"
Start-MailboxSearch "Contoso Litigation"
执行命令的用户在 Exchange 中被分配了“发现管理”角色,如下所示必需的。然而,当执行第一个命令时,它只会产生以下错误:
找不到与参数名称“AllSourceMailboxes”匹配的参数。
这文档对于 New-MailboxSearch 命令,该参数对 Exchange 2013 和 2016 均有效。此外,执行时Get-Help New-MailboxSearch
会列出以下参数:
语法
New-MailboxSearch -名称 <String> [-AllPublicFolderSources <$true | $false>][-AllSourceMailboxes <$true | $false>][-Confirm <SwitchParameter>] [-Description <String>] [-DomainController <Fqdn>] [-EndDate <ExDateTime>] [-EstimateOnly <SwitchParameter>] [-ExcludeDuplicateMessages <$true | $false>] [-Force <SwitchParameter>] [-IncludeKeywordStatistics <SwitchParameter>] [-IncludeUnsearchableItems <SwitchParameter>] [-InPlaceHoldEnabled <$true | $false>] [-InPlaceHoldIdentity <String>] [-ItemHoldPeriod <Unlimited>] [-Language <CultureInfo>] [-LogLevel <Suppress | Basic | Full>] [-MessageTypes <KindKeyword[]>] [-PublicFolderSources <PublicFolderIdParameter[]>] [-Recipients <String[]>] [-SearchQuery <String>] [-Senders <String[]>] [-SourceMailboxes <RecipientIdParameter[]>] [-StartDate <ExDateTime>] [-StatusMailRecipients <RecipientIdParameter[]>] [-TargetMailbox <MailboxIdParameter>] [-WhatIf <SwitchParameter>] [<CommonParameters>]
-AllPublicFolderSources
如果-AllSourceMailboxes
从命令中删除,参数也会出现同样的错误。
为什么这些明确记录的参数不被接受?是什么阻碍了它发挥作用?
更新
因此,我一直在研究 powershell 的工作原理,并了解到在本地执行的命令只是一个小的 powershell 函数,它通过“隐式远程处理”将命令和参数“代理”到 Exchange 服务器(Exchange 管理 Shell 基本上通过连接到服务器New-PSSession
然后执行Import-PSSession
)。真正的 cmdlet 在服务器上执行并存在于 .NET 二进制文件中。
反编译该二进制文件可发现 NewMailboxSearch 类中的以下参数:
private const string ParameterAllPublicFolderSources = "AllPublicFolderSources";
private const string ParameterAllSourceMailboxes = "AllSourceMailboxes";
private const string ParameterDescription = "Description";
private const string ParameterEstimateOnly = "EstimateOnly";
private const string ParameterExcludeDuplicateMessages = "ExcludeDuplicateMessages";
private const string ParameterForce = "Force";
private const string ParameterIncludeKeywordStatistics = "IncludeKeywordStatistics";
private const string ParameterIncludeRemoteAccounts = "IncludeRemoteAccounts";
private const string ParameterIncludeUnsearchableItems = "IncludeUnsearchableItems";
private const string ParameterInPlaceHoldEnabled = "InPlaceHoldEnabled";
private const string ParameterInPlaceHoldIdentity = "InPlaceHoldIdentity";
private const string ParameterItemHoldPeriod = "ItemHoldPeriod";
private const string ParameterLanguage = "Language";
private const string ParameterLogLevel = "LogLevel";
private const string ParameterManagedBy = "ManagedBy";
private const string ParameterMessageTypes = "MessageTypes";
private const string ParameterPublicFolderSources = "PublicFolderSources";
private const string ParameterRecipients = "Recipients";
private const string ParameterSearchQuery = "SearchQuery";
private const string ParameterSenders = "Senders";
private const string ParameterSourceMailboxes = "SourceMailboxes";
private const string ParameterStatusMailRecipients = "StatusMailRecipients";
private const string ParameterTargetMailbox = "TargetMailbox";
因此,cmdlet应该接受失败的参数。
但是,(Get-Command New-MailboxSearch).Definition
在 Exchange 命令行管理程序中执行会转储本地 powershell 函数的代码,并且那仅列出以下参数:
param(
${Description},
${DomainController},
${EndDate},
${EstimateOnly},
${ExcludeDuplicateMessages},
${Force},
${IncludeKeywordStatistics},
${IncludeUnsearchableItems},
${InPlaceHoldEnabled},
${InPlaceHoldIdentity},
${ItemHoldPeriod},
${Language},
${LogLevel},
${MessageTypes},
${Name},
${Recipients},
${SearchQuery},
${Senders},
${SourceMailboxes},
${StartDate},
${StatusMailRecipients},
${TargetMailbox}
)
因此,远程会话及其交互方式似乎存在一些问题Import-PSSession
。不幸的是,我不够专业,无法找出原因。
我尝试将缺少的参数添加到本地函数,但没有什么区别,并且您也不能在服务器上执行真正的二进制 cmdlet,因为您会收到此错误:
无法执行该任务。原因:该任务无法识别正在执行该任务的用户。
显然该 cmdlet 可以仅有的通过远程会话使用。
有人有进一步的见解吗?