I want to run a powershell in some remote machine using java. How can this be achieved.? currently this code is not running the powershell command locally.!!
<
You can try to run something like "invoke-command -computername Server1 -filepath c:\scripts\script.ps1"
Process p = new ProcessBuilder()
.inheritIO()
.command("invoke-command", "-computername", "Server1",
"-filepath", "C:\\scripts\\script.ps1").start();
p.waitFor();
but first of all make sure that this command work OK from command line.