Running Powershell script remotely through Java
I am able to run the below powershell command through Powershell itself, invoke-command -ComputerName "compName" -filepath "c:\script.ps1" -credential "admin" but when I try running that through Java, I get an error. Sounds like "Invoke-command" is not recognized as a program to be run though Java. If this is the case, is there any other solution? Process p = new ProcessBuilder() .inheritIO() .command("invoke-command", "-computername", "compName", "-filepath", "C:\\script.ps1").start(); The error, Cannot run program "invoke-command": CreateProcess error=2, The system cannot find the file