You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`PowerShell.open()` opens a new PowerShell session. You can execute a PowerShell command with `psSession.executeCommands(command)`. It will return the output of the command as a string:
If your PowerShell code has parameters that are dynamically read from Java strings, they might contain characters that have special meaning in PowerShell (kind of like SQL injection). You can sanitize your input with `PowerShell.escapePowerShellString(parameter)`:
tuupertunut.powershelllibjava.PowerShellExecutionException: Error while executing PowerShell commands:
68
-
this : The term 'this' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
69
-
...
70
-
```
71
-
72
-
## Requirements
73
-
74
-
You must have PowerShell installed on your machine.
75
-
76
-
**OS:** Windows is the only currently supported OS. This library has not been tested on Linux, but it might work.
`PowerShell.open()` opens a new PowerShell session with default executable. On Windows it is `powershell`, and on other platforms it is `pwsh` from PowerShell Core. You can also specify a custom PowerShell executable, for example `PowerShell.open("/usr/bin/pwsh-preview")`.
8
+
9
+
You can execute a PowerShell command with `psSession.executeCommands(command)`. It will return the output of the command as a string:
If your PowerShell code has parameters that are dynamically read from Java strings, they might contain characters that have special meaning in PowerShell (kind of like SQL injection). You can sanitize your input with `PowerShell.escapePowerShellString(parameter)`:
tuupertunut.powershelllibjava.PowerShellExecutionException: Error while executing PowerShell commands:
70
+
this : The term 'this' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
71
+
...
72
+
```
73
+
74
+
## Requirements
75
+
76
+
**OS:** Works on every platform that has PowerShell available.
77
+
78
+
**PowerShell:** On Windows 7 and newer, Windows PowerShell is installed by default and this library should work with it out of the box. On other platforms, you need to have PowerShell Core (https://github.com/PowerShell/PowerShell) installed.
0 commit comments