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
精彩评论