Why are ETW events not triggered when using PS in a custom PowerShell host from C sharp?
I'm executing PowerShell scripts from within a C# application using the System.Management.Automation
library. My goal is to capture script actions through ETW events from the Microsoft-Windows-PowerShell
provider. When I run the same script in the official powershell.exe host, the ETW events are captured without any issues. However, when executing the script using my custom host from C#, no ETW events are generated.
I've noticed that there are references to ETW tracing within the System.Management.Automation
assembly, which suggests that the library supports ETW. This leads me to suspect that the ETW provider is initialized only when running in the official host environment but I am not sure about it, nor have I found any documentation about.
What is the reason? Could the events be enabled?
PS version: 7.1.3
.NET version: net5.0