0
我有以下確定指標cmdlet的:調用從PS腳本中的PowerShell命令
[CmdletBinding(DefaultParameterSetName="Path",
SupportsShouldProcess=$TRUE)]
param(
[parameter(Mandatory=$TRUE,Position=0)]
[String] $Pattern,
[parameter(Mandatory=$TRUE,Position=1)]
[String] [AllowEmptyString()] $Replacement,
[parameter(Mandatory=$TRUE,ParameterSetName="Path",
Position=2,ValueFromPipeline=$TRUE)]
[String[]] $Path,
[parameter(Mandatory=$TRUE,ParameterSetName="LiteralPath",
Position=2)]
[String[]] $LiteralPath,
[Switch] $CaseSensitive,
[Switch] $Multiline,
[Switch] $UnixText,
[Switch] $Overwrite,
[Switch] $Force,
[String] $Encoding="ASCII"
)
我把該cmdlet的.ps1文件在同一文件夾中,作爲調用該cmdlet如下PowerShell腳本文件:
Invoke-Expression -Command .\Replace-FileString.ps1 "9595" "NewPort" "c:\temp" -Overwrite
然而,當我執行我的PS腳本,我得到以下錯誤:
Invoke-Expression : A positional parameter cannot be found that accepts argument '9595'. How can I make it work? Thanks.