在将参数传递到PS文件时,如何使用invoke-command从Windows命令行运行PS文件? 这是我的脚本:
#TestParams2.ps1
param (
[string]$Server,[string]$FileFolderName,[string]$VerValue
)
$Server
$FileFolderName
$VerValue
这就是我要称呼它的方式:
powershell.exe invoke-command -FilePath 'C:\temp\TestParams2.ps1' -ArgumentList 'myserver','\\server1\folder name\file.txt','9999'
当我运行它时,我得到了:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ invoke-command -FilePath 'C:\temp\TestParams2.ps1' -ArgumentList 'mys ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command],ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,microsoft.PowerShell.Commands.InvokeCommandCommand
我应该如何调用脚本?