【发布时间】:2015-02-18 23:21:14
【问题描述】:
我正在尝试使用 powershell 远程自动化安装,并且我有多个工作,最后一个不工作是在我远程进入之后,我复制文件很好,但是当我尝试执行 PS 脚本时,我失败了同样的错误。脚本和错误如下:
Enable-WSManCredSSP -Role Client -DelegateComputer $SQL_Server -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential $Secure_SQLInstaller, $Secure_SQLInstallerPassword
$Batch_exec = "\\demo.dev\SI\Start.ps1"
$Argument_list = "$SV, $SE, $DC, $SA, $SP, $SAP, $FP, $DT, $PSN, $E"
Invoke-Command -ComputerName $SQL_Server -Authentication CredSSP -credential $cred -FilePath $Batch_exec -scriptblock { Start-Process -FilePath $Batch_exec -ArgumentList $Argument_list }
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At line:110 char:2
+ Invoke-Command -ComputerName $SQL_Server -Authentication CredSSP -credential $c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
【问题讨论】:
-
另外,我知道 Argument_list 有数组的逗号,但即使我因为调用函数而将它们取出,我也会得到同样的错误。只是想记下这一点。感谢您的帮助。
-
很确定这是因为您使用的是
-FilePath和-scriptblock