profesorfalken / jPowerShell

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

executeScript is private #43

Closed hakimMaharmeh closed 6 years ago

hakimMaharmeh commented 6 years ago

Hi prof,

I need to execute a powershell script with parameters. But looking at https://github.com/profesorfalken/jPowerShell/blob/master/src/main/java/com/profesorfalken/jpowershell/PowerShell.java Both functions are private: private PowerShellResponse executeScript(String scriptPath, String params)

private PowerShellResponse executeScript(BufferedReader srcReader, String params)

So this will never work: (cf https://github.com/profesorfalken/jPowerShell ) PowerShell powerShell = PowerShell.openSession(); String script = "resourcePath/MyScript.ps1" String scriptParams = "-Parameter value"

//Read the resource
BufferedReader srcReader = new BufferedReader(
                new InputStreamReader(getClass().getResourceAsStream(script)));

if (scriptParams != null && !scriptParams.equals("")) {
    response = powerShell.executeScript(srcReader, scriptParams); ///*** ISSUE HERE ****
} else {
    response =  powerShell.executeScript(srcReader);
}

Regards

rworsnop commented 6 years ago

Was changed in 6ffb489704556b2f0d8cb60b9b60bd283e321125. No idea why.

profesorfalken commented 6 years ago

Hi,

It is strange. I guessI had passed an static code analyser that suggested changing the visibility of the method.

I will revert this. Thanks for reporting it

Best regards.

profesorfalken commented 6 years ago

Fixed in 2.1.1