-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Hi there,
Commands like Get-Date, Get-Process, etc times out when executed using JPowerShell in PowerShell 7.x.x. The same work fine in version 6.x.x. Also this happens when PowerShell is running in a Docker container. Here is a sample program to reproduce this:
**import com.profesorfalken.jpowershell.PowerShell;
import com.profesorfalken.jpowershell.PowerShellResponse;
import java.util.HashMap;
import java.util.Map;
public class psTester {
public static void main (String[] args) {
testPsCmd();
}
private static void testPsCmd() {
String responseBody = "";
int responseCode = -1;
try {
PowerShell powerShell = PowerShell.openSession("pwsh");
Map<String, String> config = new HashMap<String, String>();
config.put("maxWait", "6000");
PowerShellResponse response =
powerShell
.configuration(config)
.executeCommand("Get-Process");
responseCode = response.isError() ? 1 : 0;
responseBody = response.getCommandOutput();
powerShell.close();
} catch (Exception e) {
StringBuffer sb = new StringBuffer(e.getMessage());
}
}
}**
Here is a Dockerfile that can be used to spin up a container with JDK11 and PowerShell 7.2.7:
**FROM amazoncorretto:11 as corretto_jdk
RUN yum install -y sudo
RUN sudo yum install -y wget
RUN sudo yum install -y tar
RUN sudo yum install -y gzip
RUN sudo yum install -y curl libunwind libicu libcurl openssl libuuid.x86_64
RUN curl -L -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v7.2.7/powershell-7.2.7-linux-x64.tar.gz
RUN sudo mkdir -p /opt/microsoft/powershell/7.2.7
RUN sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7.2.7
RUN sudo chmod +x /opt/microsoft/powershell/7.2.7/pwsh
RUN sudo ln -s /opt/microsoft/powershell/7.2.7/pwsh /usr/bin/pwsh
RUN sudo ln -s /opt/microsoft/powershell/7.2.7/pwsh /usr/bin/powershell**
Please let me know if you need more information. Thanks