Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frimtec/jpse
:electric_plug: API to easily execute PowerShell commands and scripts from Java.
https://github.com/frimtec/jpse
api java linux powershell pwsh windows
Last synced: 7 days ago
JSON representation
:electric_plug: API to easily execute PowerShell commands and scripts from Java.
- Host: GitHub
- URL: https://github.com/frimtec/jpse
- Owner: frimtec
- License: apache-2.0
- Created: 2020-05-21T08:18:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-28T12:47:35.000Z (8 days ago)
- Last Synced: 2024-12-28T13:31:14.886Z (8 days ago)
- Topics: api, java, linux, powershell, pwsh, windows
- Language: Java
- Homepage:
- Size: 279 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JPSE - Java PowerShell Executor
[![setup automated][codespaces-shield]][codespaces][![Maven Central][maven-central-shield]][maven-central]
[![License][license-shield]][license]![Project Maintenance][maintenance-shield]
[![Code Coverage][codecov-shield]][codecov][![Build Status][build-status-shield]][build-status]
[![Deploy Status][deploy-status-shield]][deploy-status]API to easily execute PowerShell commands and scripts from Java.
## Supported platforms
* Windows
* Linux (with installed PowerShell)
* MacOS (with installed PowerShell)## Example
Call PowerShell commands or scripts like this:
```java
PowerShellExecutor executor = PowerShellExecutor.instance();
System.out.println("PowerShell runtime version " +
executor.version().orElseThrow(() -> new RuntimeException("No PowerShell runtime available")));System.out.println("Execute command: ");
String output = executor.execute("Write-Host Hello PowerShell!").getStandardOutput();
System.out.println(" output = " + output);Map 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][maven-central] to your software project management tool:In Maven just add the following dependency to your pom.xml:
```xml
com.github.frimtec
jpse
1.3.3
```[codespaces-shield]: https://github.com/codespaces/badge.svg
[codespaces]: https://codespaces.new/frimtec/jpse
[maven-central-shield]: https://maven-badges.herokuapp.com/maven-central/com.github.frimtec/jpse/badge.svg
[maven-central]: https://maven-badges.herokuapp.com/maven-central/com.github.frimtec/jpse
[maintenance-shield]: https://img.shields.io/maintenance/yes/2025.svg
[license-shield]: https://img.shields.io/github/license/frimtec/jpse.svg
[license]: https://opensource.org/licenses/Apache-2.0
[codecov-shield]: https://codecov.io/gh/frimtec/jpse/branch/master/graph/badge.svg?token=WHFQYWA0EA
[codecov]: https://codecov.io/gh/frimtec/jpse
[build-status-shield]: https://github.com/frimtec/jpse/workflows/Build/badge.svg
[build-status]: https://github.com/frimtec/jpse/actions?query=workflow%3ABuild
[deploy-status-shield]: https://github.com/frimtec/jpse/workflows/Deploy%20release/badge.svg
[deploy-status]: https://github.com/frimtec/jpse/actions?query=workflow%3A%22Deploy+release%22