Class Powershell

java.lang.Object
io.github.gageallencarpenter.Powershell

public class Powershell extends Object
The Powershell class provides a convenient way to execute PowerShell scripts synchronously or asynchronously.
Author:
Gage
  • Constructor Details

    • Powershell

      public Powershell()
      Creates an instance of Powershell with the maximum number of threads based on the runtime environment.
    • Powershell

      public Powershell(int threads)
      Creates an instance of Powershell with a specified number of threads.
      Parameters:
      threads - the number of threads allocated to this Powershell instance
  • Method Details

    • execute

      public List<String> execute(String script)
      Executes a PowerShell script synchronously.
      Parameters:
      script - the PowerShell script to execute
      Returns:
      the list of output lines from the script execution
    • executeAsync

      public Future<List<String>> executeAsync(String script)
      Executes a PowerShell script asynchronously.
      Parameters:
      script - the PowerShell script to execute
      Returns:
      a Future representing the asynchronous execution with the result containing the list of output lines
      Throws:
      RuntimeException - if an IOException occurs during the script execution