Esempio n. 1
0
        protected override void ProcessRecord()
        {
            try
            {
                WriteVerbose(pass);
                WriteVerbose("Query: " + query);

                SplunkConnection con = new SplunkConnection(serverUrl);
                if (login.StartsWith("\\"))
                {
                    login = login.Substring(1);
                }
                string sessionKey = con.Authenticate(login, pass);

                WriteVerbose("SessionKey: " + sessionKey);

                SearchManager searchManager = new SearchManager(con);
//                searchManager.ControlAllJobs(JobAction.CANCEL);

                SearchJob job = searchManager.SyncSearch(query, null);

                WriteVerbose("Job ID: " + job.Id);

                EventParameters ep = new EventParameters();

                if (fields != null && fields.Length > 0)
                {
                    ep.FieldList = fields;
                }

                DataTable dt = job.GetEventsTable(ep);

                WriteObject(dt);

                job.Cancel();
            }
            catch (Exception e)
            {
                WriteObject(e.Message);
            }
        }
Esempio n. 2
0
        protected override void ProcessRecord()
        {
            try
            {
                WriteVerbose(pass);
                WriteVerbose("Query: " + query);

                SplunkConnection con = new SplunkConnection(serverUrl);
                if(login.StartsWith("\\"))
                {
                    login = login.Substring(1);
                }
                string sessionKey = con.Authenticate(login, pass);

                WriteVerbose("SessionKey: " + sessionKey);

                SearchManager searchManager = new SearchManager(con);
            //                searchManager.ControlAllJobs(JobAction.CANCEL);

                SearchJob job = searchManager.SyncSearch(query, null);

                WriteVerbose("Job ID: " + job.Id);

                EventParameters ep = new EventParameters();

                if (fields != null && fields.Length > 0)
                    ep.FieldList = fields;

                DataTable dt = job.GetEventsTable(ep);

                WriteObject(dt);

                job.Cancel();
            }
            catch (Exception e)
            {
                WriteObject(e.Message);
            }
        }