Hello,
I'm just starting out with c# and WMI and have a few questions that seasoned
coders might be able to help me with. I'd like to write a console app that
would query a server and pull out all the errors in the system and
application log. I've started writing the class to do this but i'm stuck now
because I have no idea on how to do this... here's my code... any help is
appreciated.
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
#endregion
namespace EventlogWatcher
{
public class EventLog
{
// variables to store server name and event log type
private string serverName, logType;
private const string user="softlnding";
private const string password = "$0ftLand1ng";
public EventLog(string serverName, string logType)
{
this.logType = logType;
this.serverName = serverName;
}
private void GetLogs()
{
//Build an options object for the connection
ConnectionOptions options = new ConnectionOptions();
options.Username = user;
options.Password = password;
//Make a connection to a remote computer using these options
ManagementScope scope = new
ManagementScope("\\\\Server1\\root\\cimv2", options);
scope.Connect();
SelectQuery query = new SelectQuery("Select * from
Win32_NTEventLogFile Where LogFileName='Application'");
}
}
}