1

So maybe I am just ignorant, but C# has some lovely functionality with System.Diagnostics.Tracing.EventSource that make writing new event sources super simple. I've got some functionality built up around this convenient api that allows these logs to be processed after ingestion.

All of this however is being moved to powershell and I'm trying to get it working. If I consume a current implementation of a EventSource subclass through dlls everything works as expected. If I try to write a new EventSource subclass purely in powershell, the event stop showing up.

I have researched the googles quite thoroughly and it has become clear to me that this is not a standard approach. (Surprising because it is such a handy chunk of coding) Can anyone help or tell me what I may be doing wrong?

class TestEventSource2 : System.Diagnostics.Tracing.EventSource
{

static [TestEventSource2] $Log = [TestEventSource2]::New()
static [string] $LogName = "its a name"

[void] WriteTestEvent() {

    Write-Information "WriteTestEvent"
    WriteEvent(1,"Hello world from a powershell test event.")
}
}


 $loglog = [TestEventSource2]::Log
$loglog.WriteTestEvent()

0 Answers0