Please feel free to provide feedback or file bugs here.

powershell.exe -Command - is broken on Windows 10 14393

See the details at https://social.technet.microsoft.com/Forums/windowsserver/en-US/4a52d235-5b10-4e4d-9c24-c2b354a57c26/invoking-powershellexe-with-command-reading-input-from-stdin-broken-in-windows-10-14393

I wrote a post that includes the source for a tiny C# program that demonstrates that trying to launch powershell.exe with its "-Command -" parameter to get the script from StdIn no longer works after installing the Anniversary Update on Windows 10. Does not happen on Server 2016 TP5. I can duplicate the details here if that makes more sense.

34 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    _dandy_ shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    The fix for this issue has been backported from 6.0-alpha to 5.1 in the latest fully patched Win10 Anniversary Update. This repro should show powershell.exe -Command with -RedirectStandardInput working, and also demonstrates the version of PowerShell you should be on.

    C:\temp> set-content .\in.txt ‘$psversiontable’ -Encoding ascii
    >> Start-Process -FilePath ‘powershell.exe’ -ArgumentList “-Command -” -RedirectStandardOutput "out.txt
    " -RedirectStandardInput “in.txt”
    C:\temp> cat .\out.txt

    Name Value
    -- -
    PSVersion 5.1.14393.206
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
    BuildVersion 10.0.14393.206
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

    Note: if your problems aren’t fixed, and you’re on this version of PowerShell 5.1 or greater, please file another issue here on UserVoice to address it.

    Thanks!
    Joey

    9 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Mykola Gorbarov commented  ·   ·  Flag as inappropriate

        Dear Joey,

        This issue is still possible to reproduce with PSVersion: 5.1.14393.206:
        Windows PowerShell transcript start
        Start time: 20161123103734
        Username: blabla
        RunAs User: blabla
        Machine: name (Microsoft Windows NT 10.0.14393.0)
        Host Application: powershell -command -
        Process ID: 5192
        PSVersion: 5.1.14393.206
        PSEdition: Desktop
        PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.206
        BuildVersion: 10.0.14393.206
        CLRVersion: 4.0.30319.42000
        WSManStackVersion: 3.0
        PSRemotingProtocolVersion: 2.3
        SerializationVersion: 1.1.0.1

        Can You review fix?

      • Florian Lusch commented  ·   ·  Flag as inappropriate

        @Joey Aiello
        Could you pleae tell us, which KB we have to install to fix this error in Windows 10?

      • Glenn Sarti commented  ·   ·  Flag as inappropriate

        Zachary, Thanks for updating this issue. Will this fix be backported to 5.1 as that repo is for Powershell 6.0?

      • _dandy_ commented  ·   ·  Flag as inappropriate

        > We would love to see this fix backported to the PowerShell 5.1 Anniversary edition

        I can't see how anyone could get away with not doing that.

      • Ethan Brown commented  ·   ·  Flag as inappropriate

        Our assumption is that this will also impact the latest builds of Server 2016, which build on PowerShell 5.1.

      • Mike Sargent commented  ·   ·  Flag as inappropriate

        One of the devs at my company is fighting with this issue. Clearly, something got broken with the Anniversary Update and it needs to be fixed!

      Feedback and Knowledge Base