You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To start - executeCommand() works perfect in this scenario, just not calling a script file
First I'm setting the filePath of the script: String filePath = "C:\\Users\\userName\\projectName\\scripts\\test.ps1";
Then I used a bit of code from jPowerShell to ensure the file is readable: BufferedReader srcReader = new BufferedReader(new FileReader(new File(filePath)));
Then I call the script: PowerShellResponse psResponse = powerShell.executeScript(filePath);
Get the output: String output = psResponse.getCommandOutput();
Return the output to the page: response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<pre>"); out.println("Executing: " + script); out.println(output); out.println("</pre>");
The above works great when using executeCommand() but the executeScript() method doesn't even error, the response is just empty
The powershell script is super simple: function getData() { $result = Get-Process return $result } getData
Is there something I'm doing wrong here?
Thanks!
The text was updated successfully, but these errors were encountered:
To start - executeCommand() works perfect in this scenario, just not calling a script file
First I'm setting the filePath of the script:
String filePath = "C:\\Users\\userName\\projectName\\scripts\\test.ps1";
Then I used a bit of code from jPowerShell to ensure the file is readable:
BufferedReader srcReader = new BufferedReader(new FileReader(new File(filePath)));
Then I call the script:
PowerShellResponse psResponse = powerShell.executeScript(filePath);
Get the output:
String output = psResponse.getCommandOutput();
Return the output to the page:
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<pre>");
out.println("Executing: " + script);
out.println(output);
out.println("</pre>");
The above works great when using executeCommand() but the executeScript() method doesn't even error, the response is just empty
The powershell script is super simple:
function getData() {
$result = Get-Process
return $result
}
getData
Is there something I'm doing wrong here?
Thanks!
The text was updated successfully, but these errors were encountered: