1

I am trying to call FormatDescription(ienumerable) of an EventRecord but cannot get it to replace the strings. What am I doing wrong?

    public void StartLogReading()
    {          
        EventLogQuery evtLogQuery = new EventLogQuery(
            "Application",
            PathType.LogName,
            "*[System/EventRecordID >= 0]");

        var watcher = new EventLogWatcher(evtLogQuery, null, true);
        watcher.EventRecordWritten += EventLogEventRead;
        watcher.Enabled = true;

    }

    private void EventLogEventRead(object sender, EventRecordWrittenEventArgs e)
    {
        List<object> aParams = new List<object>();
        foreach (EventProperty eventProperty in e.EventRecord.Properties)
        {
            aParams.Add(eventProperty.Value);
        }
        string description = e.EventRecord.FormatDescription(aParams);
        // Do stuff with description
    }

The string description always contains the event message without the params being replaced.

I am actually trying to use this technique as a workaround for the exception I get sometimes: "The description string for parameter reference (%1) could not be found" when calling e.EventRecord.FormatDescription().


How to scrape a website using powershell and then trimming the output to a single date

Sorry if this is a duplicate, I can't seem to find my first iteration of this question. I am trying to scrape a website to produce the date of an updated app. My code produces two dates, so I'd like to know how to trim that down to one string, which in this case should be October 31, 2018. I know how to manipulate it after that for my use but am stuck in how to trim the output.

$months = "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"

$response = Invoke-WebRequest -Uri "https://play.google.com/store/apps/details?id=com.airwatch.androidagent&hl=en_US"

$data = ($response.ParsedHtml.getElementsByTagName('span') | Where {$_.className -eq 'htlgb'} ).innerText

$data | Select-String -Pattern $months
4

0 回答 0