Aggregate Count of 1 Objects in Group-By

Welcome Forums General PowerShell Q&A Aggregate Count of 1 Objects in Group-By

Viewing 14 reply threads
  • Author
    Posts
    • #242423
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      Trying to output:

      • This topic was modified 2 months, 1 week ago by tluizzi.
    • #242426
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant
    • #242429
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant
      <colgroup><col style=”width: 48pt;” span=”2″ width=”64″ /> </colgroup>

      Name IRNumber
      Last, First1 Not Found
      Last, First2 Not Found
      Last, First3 Not Found
      Last, First4 Not Found
      Last, First5 Not Found
      Last, First6 Not Found
      Last, First7 Not Found
      Last, First8 Not Found
      Last, First9 Not Found
      Last, First10 Not Found
      Last, First01 Service Account
      Last, First02 Service Account
      Last, First03 Service Account
      Last, First04 Service Account
      Last, First05 Service Account
      Last, First06 Service Account
      Last, First07 Service Account
      Last, First08 Service Account
      Last, First09 Service Account
      Last, First10 Service Account
      Last, First 20 Local Admin Account
      Last, First 21 Local Admin Account
      Last, First 22 Local Admin Account
      Last, First 23 Local Admin Account
      Last, First 24 Local Admin Account
      Last, First 25 Local Admin Account
      Last, First 26 Local Admin Account
      Last, First 27 Local Admin Account
      Last, First 28 Local Admin Account
      Admin1 Domain Admin
      Admin2 Domain Admin
      Admin3 Domain Admin
      Last, First 36 IR56242
      Last, First 43 IR56242
      Last, First 46 IR56242
      Last, First 48 IR56242
      Last, First 55 IR56242
      Last, First 50 IR44372
      Last, First 33 IR42115
      Last, First 32 IR29068
      Last, First 32 IR29068
      Last, First 32 IR29068
      Last, First 40 IR27733
      Last, First 49 IR243582
      Last, First 37 IR243581
    • #242438
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant
    • #242441
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      I am having troubling posting the sample audit data (maybe too much text?)

      You may ask in the forum Web Site Feedback & Assistance to release your post from moderation. I think most of the time the problem is when you edit your post to often in a shorter amount of time.

      You don’t have to post all original data. Only as much to be able to reproduce your situation. I think 5 to 15 rows of data should be enough. ūüėČ

    • #242444
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      This provides an output very similar to your desired output I think:

      [/crayon]
    • #242450
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      My apologies to all the moderators out there ūüôā

      Thanks for the input, Olaf!¬† I’m going to try to write a PSCustomObject – your foreach-object loop sparked an idea.

      I intend to use this object as input into a pie chart or other visualization.¬† I’m confident I can build a report using R and Markdown but I’d like to keep my script Powershell-pure.¬† A few SYTLE tags with some CSS and flexbox classes go a long way.

    • #242582
      Participant
      Topics: 13
      Replies: 1753
      Points: 3,136
      Helping Hand
      Rank: Community Hero

      Are you just wanting non-unique groups?

    • #242609
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      Hi Rob,

      I am trying aggregate all objects that have a count of 1 into one object:

    • #242618
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      I got it ūüôā

      (I am using a different data set)

      • This reply was modified 2 months ago by tluizzi.
      • This reply was modified 2 months ago by tluizzi.
    • #242645
      Participant
      Topics: 7
      Replies: 557
      Points: 2,122
      Helping Hand
      Rank: Community Hero

      How about something like this?

      Output

    • #242675
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      Thanks for feedback gentlemen. Doug, an issue I see with your solution is that you have to know ahead of time how many unique groups there are:

      Thanks for the code snipit – I wasn’t aware that you can assign two variables at once.

      Here’s another example I wrote:

      • This reply was modified 2 months ago by tluizzi.
    • #242714
      Participant
      Topics: 7
      Replies: 557
      Points: 2,122
      Helping Hand
      Rank: Community Hero

      I could see why you’d think that, but that is not the case. The number 5 indicates the where operation mode “split” – here are all the modes

      This should make it clearer to see.

      And for reference https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.whereoperatorselectionmode?view=powershellsdk-7.0.0

    • #242717
      Participant
      Topics: 6
      Replies: 16
      Points: 111
      Rank: Participant

      Thanks for explanation, Doug, this is great!

    • #242948
      Participant
      Topics: 13
      Replies: 1753
      Points: 3,136
      Helping Hand
      Rank: Community Hero

      That is an interesting solution Doug. It’s always fun when you can find a use case for an obscure functionality in programming.

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