Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executeScript() issues #83

Open
dschwartz0815 opened this issue May 19, 2023 · 2 comments
Open

executeScript() issues #83

dschwartz0815 opened this issue May 19, 2023 · 2 comments

Comments

@dschwartz0815
Copy link

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!

@dschwartz0815
Copy link
Author

Forgot to mention - I've also tried just putting the full file path of the script in the method as well rather than using the variable. Same result

@dschwartz0815
Copy link
Author

Update - problem is solved after applying the tempFolder config parameter. Set it to the same dir as the script I'm loading and it's working now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant