powershell : Cannot process the XML from the 'Error' stream

See original GitHub issue

Steps to reproduce

powershell -c {[console]::Error.Write('abc')} 2>&1`

Expected behavior

powershell : abc
At line:1 char:6
+ $q = powershell -c "[console]::Error.Write('abc')" 2>&1
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (abc:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Actual behavior

powershell : Cannot process the XML from the 'Error' stream of
'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe': Data at the root level is invalid. Line 1, position 1.
At line:1 char:1
+ powershell -c {[console]::Error.Write('abc')} 2>&1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SyntaxError: (C:\WINDOWS\Syst...\powershell.exe:String) [], XmlException
    + FullyQualifiedErrorId : ProcessStreamReader_CliXmlError

Environment data

This repros on Full Framework build and on inbox PS v5.1 on Windows.

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14393.0
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.0
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      WindowsPowerShell
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.7-117-gbbddfe81a5a72f45e4a650cf3f42a0ca1eda86aa
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vorscommented, Jun 15, 2019

Doesn’t repro for me on 7.0.0-beta1 on mac.

0reactions
jszabo98commented, May 6, 2019

Fixed (unicode no bom)? (pwsh not powershell)

PS C:\users\js> powershell -c {[console]::Error.Write('abc')} 2>&1
powershell : Cannot process the XML from the 'Error' stream of 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe': Data at the root level is invalid. Line 1, position 1.
At line:1 char:1
+ powershell -c {[console]::Error.Write('abc')} 2>&1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : SyntaxError: (C:\Windows\Syst...\powershell.exe:String) [], XmlException
+ FullyQualifiedErrorId : ProcessStreamReader_CliXmlError

PS C:\users\js> pwsh -c {[console]::Error.Write('abc')} 2>&1
abc

PS C:\users\js> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.2
PSEdition                      Core
GitCommitId                    6.1.2
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Executing PsExec64.exe from Poweshell throwing "Cannot ...
From my PowerShell script I am executing PSExec64.exe with below ... PsExec64.exe : Cannot process the XML from the 'Error' stream of ...
Read more >
XML Error (Data at the root level is invalid) : r/PowerShell
Hello, I'm having an issue with a PowerShell script that I'm trying to ... Error: Cannot convert value "System.Object[]" to type "System.
Read more >
Q: What's the proper way to run inspec under Windows?
inspec : Cannot process the XML from the 'Error' stream of 'c:\opscode\inspec\bin\inspec.bat': Root element is missing.
Read more >
Write-Error (Microsoft.PowerShell.Utility)
The Write-Error cmdlet declares a non-terminating error. By default, errors are sent in the error stream to the host program to be displayed, ......
Read more >
PowerShell v2 task reports error code 1 when pwsh
let's say i have a bug and used a command with a required param e.g. write-verbose then if i want to run it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found