Sort Eventlog per machine name

Welcome Forums General PowerShell Q&A Sort Eventlog per machine name

Viewing 2 reply threads
  • Author
    Posts
    • #252191
      Participant
      Topics: 5
      Replies: 1
      Points: 66
      Rank: Member

      Hello,

      I am struggling with a script to show me the number of entry’s for a system log, in a array of servers.
      My script shows me the log, that I need, also the number of entry’s only I cannnot get it to work that it shows me a output basedon an per server.

      Like :
      Server 1
      Count     source    eventid   message
      —–          ——     ——-      ——
      ——        ——–   ——–   ——–
      Server 2
      Count  Source   eventid   Message
      ——       —–       ——-     ——
      ——–   ——–   ——–   ——–
      I tried a number of  ways, only I miss still some experience in this part it seems..:-)

      ————————–

      • This topic was modified 1 month ago by PBA121137. Reason: edited because i did not use the preformatted text for code :)
    • #252212
      Participant
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      Try something like this which gets all of the results and then groups them:

    • #252230
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      I’m not sure if you’re trying to count each source or just the amount of events in total. Based on the code you have, if you simply change the calculated property as shown here

      You end up with output like this

      I also removed the foreach loop as it’s hurting your execution time. Since you already have the list of servers, if you pass that list directly to Invoke-Command it will run them in parallel. It also returns by default a PSComputerName so we just inserted that to the caclulated servername property. If this is not the output you expected, please try to clarify what you wanted to end up with.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.