Skip to content

EventLog access is not supported on this platform #4

@mwithheld

Description

@mwithheld

When I run the sample code as admin:

#test-posheventlog.ps1
Import-Module PoShLog
Import-Module PoShLog.Sinks.EventLog
New-Logger |
    Add-SinkEventLog -Source 'PoshLogs' |
    Start-Logger
Write-InformationLog 'My message in windows event log'
Close-Logger

I get this error:

PS C:\Scripts\> .\test-posheventlog.ps1
Exception calling "EventLog" with "9" argument(s): "EventLog access is not supported on this platform."
At C:\Program Files\WindowsPowerShell\Modules\PoShLog.Sinks.EventLog\1.0.0\functions\sinks\Add-SinkEventLog.ps1:56 char:3
+         $LoggerConfig = [Serilog.LoggerConfigurationEventLogExtension ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PlatformNotSupportedException

I have registered the event source as admin, and tested this works:

New-EventLog -LogName Application -Source PoshLogs
Write-EventLog -LogName "Application" -Source "PoshLogs"

I tried a fresh re-install of .NET 6.0.14 SDK and full machine restart.
Install was fresh today:

Install-Module -Name PoShLog
Install-Module PoShLog.Sinks.EventLog

Windows Server 2019
Powershell 7.3.3

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name version -EA 0 | Where { $_.PSChildName -Match '^(?!S)\p{L}'} | Select PSChildName, version

PSChildName Version  
----------- -------  
Client      4.7.03190
Full        4.7.03190
Client      4.0.0.0  

Any suggestions would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions