我正在尝试创建一个New-WebServiceProxy
用作参数的函数,但出现错误。我的功能代码:
function Execute-SOAPRequest () {
[CmdletBinding()]
Param
(
[Parameter(Position = 0, Mandatory = $true)]
[New-WebServiceproxy]$myService,
[Parameter(Position = 1, Mandatory = $true)]
[String]$url
)
write-host "Sending SOAP Request To Server: $url"
$myService.getUsers()
}
错误信息:
At C:\myService.ps1:6 char:12 + [New-WebServiceproxy]$myService, + ~ Missing ] at end of attribute or type literal. At C:\myService.ps1:6 char:13 + [New-WebServiceproxy]$myService, + ~ Parameter declarations are a comma-separated list of variable names with optional initializer expressions. At C:\myService.ps1:6 char:13 + [New-WebServiceproxy]$myService, + ~ Missing ')' in function parameter list. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfAttribute
它不喜欢用破折号分隔的参数名称 [New-WebServiceproxy]。如何处理?