code: private void readData(StringBuilder powerShellOutput) throws IOException {
          String line;
          while (null != (line = this.reader.readLine())) {
  
              //In the case of script mode it finish when the last line is read
              if (this.scriptMode) {
                  if (line.equals(PowerShell.END_SCRIPT_STRING)) {
                      break;
                  }
              }
  
              powerShellOutput.append(line).append(CRLF);
  
              //When not in script mode, it exits when the command is finished
              if (!this.scriptMode) {
                  try {
                      if (this.closed || !canContinueReading()) {
                          break;
                      }
                  } catch (InterruptedException ex) {
                      Logger.getLogger(PowerShellCommandProcessor.class.getName()).log(Level.SEVERE, "Error executing command and reading result", ex);
                  }
              }
          }
      }
docs: Reads all data from output