开发者

How can I use python to read windows eventlog from a remote machine?

开发者 https://www.devze.com 2023-01-30 16:08 出处:网络
I\'m working on retrieving the Windows eventlog from a remote machine using Python. I tried the following code:

I'm working on retrieving the Windows eventlog from a remote machine using Python.

I tried the following code:

import win32evtlog 

server = 'aRemoteMachineHostName' 
logtype = 'System' 
hand = win32evtlog.OpenEventLog(server,logtype)
total = win32evtlog.GetNumberOfEventLogRecords(hand)

and I get an access denied error.

Then I tried use win32security.Logon to do the authentication before I access the ev开发者_开发百科entlog. But I find in the win32security.Logon document, it says the API only supports local logon.

So, I'm a little bit stuck here. I wonder whether Python can do a remote Windows logon? Any tips or hints will be helpful.

Thanks.


might be easier to use snmp


As long as the user who is executing the script has the credentials to connect and read the event log, this ActiveState Recipe works for me. I've used it in a few different situations.

ActiveState WinEvtLogViewer

0

精彩评论

暂无评论...
验证码 换一张
取 消