vscode-powershell: `Write-Output` broken

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Edit: Changed title to remove “for elevated accounts” as it is now not working at all regardless of account used.

The PowerShell Extension is not starting correctly. I worked with folks over at discord who guided me through finding the issue. Attaching diagnostic log files for review as well as screen shots of the symptoms. Essentially I cannot get output from scripts I’m writing in VSCode in the PowerShell Extension terminal window

WARNING: In development mode but PowerShellEditorServices dev module path cannot be found (or has not been built yet): c:\Users\u598743a.vscode\extensions\PowerShellEditorServices\module

PowerShell Version

PS C:\Users\u598743a\.vscode> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

PS C:\Users\u598743a\.vscode> code --version
1.67.2
c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
x64

Extension Version

PS C:\Users\u598743a\.vscode> code --list-extensions --show-versions | select-string powershell

ms-vscode.powershell@2022.5.1

Steps to Reproduce

Just run a script, run a code snippet and nothing gets returned. Interestingly though if I change my code to write-host instead of write-output then I get results to the Extension’s terminal.

Visuals

2022-05-19 08_56_48-Window CorrectOutput MissingOutput NoOutputGCI NoOutPutPSVersion PSVersion

Logs

vscode-powershell.log EditorServices.log StartEditorServices.log

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 46 (18 by maintainers)

Most upvoted comments

Ok! v2023.5.4-preview is out and available for testing. I hope it’s resolved everything 🙏 if not, then you definitely have something else going on, but I was very happy to be able to repro this with Patrick and see at least a very real bug with a transcription running, in PowerShell 5.1, with a known cause and a verifiable (if not unit-testable) fix. Please enjoy your vacation! Don’t worry about getting back to us too soon. I need to start writing some talks any how.

I will.

I just got back in from vacation and am glad baywack said something, reminded me to test this. Can confirm it’s finally working. Thank you so much Andy @andschwa , this has been a really weird issue to track down. Appreciate your efforts to get it fixed up!

PS C:\PSScripts> write-host 'a'
a
PS C:\PSScripts> get-date

Tuesday, June 6, 2023 8:36:00 AM

So far so good in my testing! I’ve been running 5.4-preview for the last few days and all the previous steps I was able to complete to reproduce the issue have stopped. Thank you so much @andschwa for pushing through this. It was an annoying bug for me to deal with and sounds like you got to join in the fun as well 😃

Ok, we got it in PowerShell/PowerShellEditorServices#2031. Tested and verified by @SeeminglyScience and myself. I’ll get a pre-release out soon, and if it still doesn’t work for you then we’ll have to revisit because we can absolutely repro the TranscribeOnly bug and verify the fix in that PR. We just goofed a bit because it’s…complicated.

Thank you Andy! I’ll try to test it out in the next day or two. I’m on vacation this week so trying hard to stay away from my workstation when I can. 🙂

Well…it’s take three. Define constants got messed up. So sorry. This has been a doozy. I tested it too which is the weird thing. Maybe it’s a compilation order issue…I don’t know for sure.

Here’s something interesting about this. I just found it. When I’m developing with PS 5.1 and I set a breakpoint to debug, while in debug mode I can get results. As soon as I exit debug mode the terminal stops giving me output. image