Skip to content

Latest commit

History

408 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

JPSE - Java PowerShell Executor

Maven CentralLicense

Project MaintenanceCode Coverage

Build StatusDeploy Status

API to easily execute PowerShell commands and scripts from Java.

Supported platforms

  • Windows
  • Linux (with installed PowerShell)
  • MacOS (with installed PowerShell)

Compatible JDK's

  • 17
  • 21
  • 25

Example

Call PowerShell commands or scripts like this:

PowerShellExecutorexecutor = PowerShellExecutor.instance();
System.out.println("PowerShell runtime version " +
executor.version().orElseThrow(() -> newRuntimeException("No PowerShell runtime available")));
System.out.println("Execute command: ");
Stringoutput = executor.execute("Write-Host Hello PowerShell!").getStandardOutput();
System.out.println(" output = " + output);
Map<String, String> arguments = Collections.singletonMap("name", "PowerShell");
System.out.println("Execute script as file: ");
output = executor.execute(Paths.get(".\\src\\test\\resources\\test.ps1"), arguments).getStandardOutput();
System.out.println(" output = " + output);
System.out.println("Execute script from classpath: ");
output = executor.execute(PowerShellTestApplication.class.getResourceAsStream("/test.ps1"), arguments).getStandardOutput();
System.out.println(" output = " + output);

Add dependency

To use jpse in your project you can add the dependency from maven central to your software project management tool:

In Maven just add the following dependency to your pom.xml:

 <dependency>
<groupId>com.github.frimtec</groupId>
<artifactId>jpse</artifactId>
<version>1.4.0</version>
</dependency>

About

🔌 API to easily execute PowerShell commands and scripts from Java.

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages