profesorfalken / jPowerShell

Simple Java API to interact with PowerShell console
Apache License 2.0
217 stars 84 forks source link

response.getCommandOutput() prints blank #65

Open madhav-bharadwaj opened 5 years ago

madhav-bharadwaj commented 5 years ago

I have the below code which executes a powershell command and prints the output. I want the output to be printed to the logs so that the user knows if in case there is an error in command execution.

PowerShellResponse response = powerShell.executeCommand("$Session = New-PSSession -ComputerName "+hostname+" -Credential $cred"); System.out.println("response---"+response.getCommandOutput());

When I try to print the output when the session command is not successfull, it prints blank. Not sure what i'm doing wrong here. Can you please help.

jenskreidler commented 1 year ago

Most commonly this is a timeout for multiple reasons. Check response.isTimeout() Check any of your calls directly first using the Powershell console. Yes, I agree, one could improve the logging in jPowerShell in order to see a history of command/timeouts/errors and so forth. The timeout stuff is as far as I know not logged. Additionally we could provide slf4j thoroughly in all sources