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