0
我在传递参数问题Invoke-Command
,我已经使用-Args
和-ArgumentList
无济于事尝试。参数传递到调用命令
function One {
$errcode = $args
$username = "Ron"
$password = ConvertTo-SecureString -String "Baxter" -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$cred
$Result = Invoke-Command -ComputerName MyPc -ScriptBlock { & cmd.exe /c "C:\Scripts\test.bat" Param1 $errcode ; $lastexitcode} -Credential $cred
echo $result
}
One 10
你得到的错误? –
不是这样,所有返回的是'ECHO已打开'。 – RonBurgundy