New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__PSDumpAMSILogContent debug logging sent to stdout #21497
Comments
I agree that As an aside: an outside caller - unfortunately - sees all of PowerShell's output streams including
|
Of course it would do that™ .....
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Agree that the logging should be going to stderr, but not clear to me how this might affect existing tools relying on this. I don't see any tests using this special env var. |
There is a whole world out there! It is built into every production release, and anyone can use it for whatever purposes. I was using it to track down a performance issue. It is quite 'illuminating' to see the volume of traffic sent to AMSI during what one might consider are normal script operations. |
@rhubarb-geek-nz your usage is dumping to the console interactively. My question is if there's any tools that rely on it going to stdout which would break if we change it to stderr. |
A global GitHub code search for Also, the variable isn't documented. |
The WG reviewed this and agreed that this is a bucket 3 breaking change (thanks @mklement0 for the code search) and accept making the change to write to STDERR. We believe the env var is a carryover from WinPS5.1 and used as a test hook. |
I made the change, but now noticed an unexpected behavior. With the Console.WriteLine() calls now Console.Error.WriteLine(), you don't get ANY output in the interactive shell. STDERR is only written if you call pwsh itself. It might make more sense to just remove this env var altogether as it's not useful expect as a test hook. |
It was useful to demonstrate that AMSI logging was implemented on Linux, I think that writing a real AMSI module to demonstrate the volume and verbosity of the PowerShell logging would be an alternative approach. ( outside of the scope of this PowerShell project ). While not so easy to demonstrate with a simple script it would show what PowerShell is leaking from the process. |
Prerequisites
Steps to reproduce
When enabling AMSI debug logging the log is written to stdout, this mixes in with the success stream. It should be written to stderr.
Expected behavior
When $env:__PSDumpAMSILogContent='1' is set the extra logging should go to stderr
Actual behavior
When $env:__PSDumpAMSILogContent='1' is set the extra logging goes to stdout
Error details
no error other reported by system
Environment data
Visuals
The text was updated successfully, but these errors were encountered: