twasbrillig
twasbrillig

Reputation: 18851

Python equivalent of PowerShell Get-EventLog

In PowerShell you can run this command to list all of the different Event Log folders on a server:

Get-EventLog -list

Is there a way to do this in Python? I've seen many posts about how to get logs from a specific folder (using e.g. win32evtlog), but not how to retrieve a list of all the Event Log folders. I'm running Windows Server 2008.

Upvotes: 1

Views: 609

Answers (1)

twasbrillig
twasbrillig

Reputation: 18851

Figured it out.

>>> import win32evtlog
>>> x = win32evtlog.EvtOpenChannelEnum()
>>> win32evtlog.EvtNextChannelPath(x)
u'Application'
>>> win32evtlog.EvtNextChannelPath(x)
u'HardwareEvents'
>>> win32evtlog.EvtNextChannelPath(x)
u'Internet Explorer'
>>>

Upvotes: 1

Related Questions