Sort Eventlog per machine name

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

Viewing 2 reply threads
  • Author
    • #252191
      Topics: 10
      Replies: 6
      Points: 142
      Rank: Participant


      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 5 months ago by PBA121137. Reason: edited because i did not use the preformatted text for code :)
    • #252212
      Topics: 17
      Replies: 1958
      Points: 4,020
      Helping Hand
      Rank: Community Hero

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

    • #252230
      Topics: 9
      Replies: 707
      Points: 2,848
      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
  • The topic ‘Sort Eventlog per machine name’ is closed to new replies.