을 통해 나는,실행 PowerShell 스크립트를 원격 자바
invoke-command -ComputerName "compName" -filepath "c:\script.ps1" -credential "admin"
을 파워 쉘 자체를 통해 아래의 PowerShell 명령을 실행할 수 있어요하지만 난 자바를 통해 그것을 실행하려고하면 오류가 발생합니다. "Invoke-command"와 같은 소리는 Java로 실행되는 프로그램으로 인식되지 않습니다. 이 경우 다른 해결책이 있습니까?
Process p = new ProcessBuilder()
.inheritIO()
.command("invoke-command", "-computername", "compName",
"-filepath", "C:\\script.ps1").start();
오류 ,
"호출-명령을"프로그램을 실행할 수 없습니다 : CreateProcess를 오류 = 2, 파일을 찾을 수 없습니다 지정한
P.S. 이 오류는 제공되는 filePath와 관련이 없으며 invoke-command 자체 주위에 있습니다.
감사합니다.
을'호출-command'는 Windows 명령하지 않습니다, 그것은 PowerShell 명령이, 당신 때문에 PowerShell 명령 줄 (예 : powershell.exe -Command your-command-here')을 통해 실행해야합니다. – Andreas