首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PowerShell ParameterBindingException

PowerShell ParameterBindingException
EN

Stack Overflow用户
提问于 2011-04-30 10:32:40
回答 1查看 13K关注 0票数 7

我目前正在构建一个应用程序,以自动化一些Exchange2010操作从一个ASP.NET MVC网站。

现在,当我尝试调用New命令时,我遇到了一个ParameterBindingException。

我正在尝试创建以下调用(此调用有效):

代码语言:javascript
复制
new-AddressList -Name "7 AL" -RecipientContainer "myDomain.local/Customers/7" -IncludedRecipients 'AllRecipients' -Container '\' -DisplayName "7 AL"

我是这样做的:

代码语言:javascript
复制
var NewAddressList = new Command("New-AddressList");
NewAddressList.Parameters.Add("Name", "7 AL");
NewAddressList.Parameters.Add("RecipientContainer", "myDomain.local/Customers/7");
NewAddressList.Parameters.Add("IncludedRecipients", "AllRecipients");
NewAddressList.Parameters.Add("Container", @"\");
NewAddressList.Parameters.Add("DisplayName", "7 AL");
CommandsList.Add(NewAddressList);

此命令列表提供给我调用的管道,给出了以下错误:

:输入对象不能绑定到命令的任何参数,因为命令不接受管道输入或输入,而且其属性与接受管道输入的任何参数不匹配。

ParameterBindingException

  • FullyQualifiedErrorId:

  • CategoryInfo: InvalidArgument:(7:PSObject)

有什么线索可以导致这一切吗?

带有跟踪命令的输出:

代码语言:javascript
复制
PS C:\Users\ext_kefu> Trace-Command -Name parameterbinding -Expression {New-AddressList -Name "7 AL" -RecipientContainer "myDomain.local/Customers/7" -IncludedRecipients 'AllRecipients' -Container '\' -DisplayName "7 AL"} -PSHost
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [New-AddressList]
DEBUG: ParameterBinding Information: 0 :     BIND arg [7 AL] to parameter [Name]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [7 AL] to param [Name] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [myDomain.local/Customers/7] to parameter [RecipientContainer]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdParameter]
DEBUG: ParameterBinding Information: 0 :             Trying to convert argument value from System.String to Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdParameter
DEBUG: ParameterBinding Information: 0 :             CONVERT arg type to param type using LanguagePrimitives.ConvertTo
DEBUG: ParameterBinding Information: 0 :             CONVERT SUCCESSFUL using LanguagePrimitives.ConvertTo: [myDomain.local/Customers/7]
DEBUG: ParameterBinding Information: 0 :         BIND arg [myDomain.local/Customers/7] to param [RecipientContainer] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [AllRecipients] to parameter [IncludedRecipients]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Nullable[Microsoft.Exchange.Data.Directory.Recipient.WellKnownRecipientType]]
DEBUG: ParameterBinding Information: 0 :             Trying to convert argument value from System.String to System.Nullable[Microsoft.Exchange.Data.Directory.Recipient.WellKnownRecipientType]
DEBUG: ParameterBinding Information: 0 :             CONVERT arg type to param type using LanguagePrimitives.ConvertTo
DEBUG: ParameterBinding Information: 0 :             CONVERT SUCCESSFUL using LanguagePrimitives.ConvertTo: [AllRecipients]
DEBUG: ParameterBinding Information: 0 :         BIND arg [AllRecipients] to param [IncludedRecipients] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [\] to parameter [Container]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [Microsoft.Exchange.Configuration.Tasks.AddressListIdParameter]
DEBUG: ParameterBinding Information: 0 :             Trying to convert argument value from System.String to Microsoft.Exchange.Configuration.Tasks.AddressListIdParameter
DEBUG: ParameterBinding Information: 0 :             CONVERT arg type to param type using LanguagePrimitives.ConvertTo
DEBUG: ParameterBinding Information: 0 :             CONVERT SUCCESSFUL using LanguagePrimitives.ConvertTo: [\]
DEBUG: ParameterBinding Information: 0 :         BIND arg [\] to param [Container] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [7 AL] to parameter [DisplayName]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [7 AL] to param [DisplayName] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [New-AddressList]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [New-AddressList]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing

Name                      DisplayName               RecipientFilter
----                      -----------               ---------------
7 AL                      7 AL                      Alias -ne $null
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-13 08:32:21

我发现每个命令都必须单独调用,因为它们不相关。这个问题源于我对Powershell管道概念的误解。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5841163

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档