I am using below Microsoft code to download Event Logs from a remote server with IP.
When I try to execute code, it throws errors:
System.UnauthorizedAccessException: 'Attempted to perform an unauthorized operation.'
The exception is very clear as I have not provided authentication in the code. I am executing this code from my local computer whereas IP is of a remote computer.
I want to know how to provide authentication information.
EventLog[] remoteEventLogs;
remoteEventLogs = EventLog.GetEventLogs("xx.xxx.xx.xx");
Console.WriteLine("Number of logs on computer: " + remoteEventLogs.Length);
foreach(EventLog log in remoteEventLogs){
Console.WriteLine("Log: " + log.Log);
}