8000 Start-Process: allow redirecting std output/error to console stream · Issue #18026 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Start-Process: allow redirecting std output/error to console stream #18026
@aetonsi

Description

@aetonsi

Summary of the new feature / enhancement

Hello.
I am trying to start a process in a new window with Start-Process and i'm -waiting for its execution.

Then i need to process its output. I would like to do it all in memory, without writing to disk, as the output is confidential. Unfortunately at the moment this doesn't seem to be possible (correct me if i'm wrong) without resorting to .NET implementations like this...

Currently, this is the best you can do:

$output = & {start-process powershell "read-host 'Enter string: '" -Wait -RedirectStandardOutput output.txt ; get-content output.txt}

In this example,

  • powershell "read-host 'Enter string: '" is my command with confidential output.
  • -Wait waits for my command to exit
  • -RedirectStandardOutput permits the redirection to a file
  • get-content simply reads back that file.

Proposed technical implementation details (optional)

A possible solution would be a parameter like -RedirectStandardOutputToStream / -RedirectStandardErrorToStream

$output = & {start-process powershell "read-host 'Enter string: '" -wait -RedirectStandardOutputToStream 1}

Where 1 is the ID of the success stream.


Or, more simply:

$output = & {start-process powershell "read-host 'Enter string: '" -wait -GetStandardOutput}

... with the corresponding -GetStandardError

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0