且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Java远程运行Powershell脚本

更新时间:2023-02-03 21:10:57

在编写 invoke-command 是Powershell命令时,因此必须调用Powershell tu来运行该命令,如下所示:

As you wrote invoke-command is a Powershell command, thus you have to call Powershell tu run the command like so:

Process p = new ProcessBuilder()
                .inheritIO()
                .command("powershell", "invoke-command", "-computername", "compName",
                        "-filepath", "C:\\script.ps1").start();