Sum Unique Items in Group-Object

Hello friends, I need help developing a PowerShell-esque solution to aggregating unique objects in a Group-Object output. My code so far returns

$audit | Group-Object -Property IRNumber -NoElement | Sort-Object -Property Count -Descending
Count Name
----- ----
99 Not Found
18 IR56000
12 IR57000
10 Service Account
9 Local Admin Account
3 Domain Admin
1 IR123456
1 IR123457
1 IR123458
1 IR123459
1 IR123460

I am trying to sum all the objects that have a count of 1 and aggregate them into one object (the Count:5 Name: Unique IR)

Count Name
----- ----
   99 Not Found
   18 IR56000
   12 IR57000
   10 Service Account
    9 Local Admin Account
    3 Domain Admin
    5 Unique IR

Thanks!

 

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
Dux, Frank IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 IR56242
Last, First 70 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

Thomas
How about sharing some sample data to play with? :wink: … formatted as code as well please.

Hello, thanks for helping. This sample data is different from what I provided up.

$auditSample = @"
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, First11",Not Found
"Last, First12",Not Found
"Last, First13",Not Found
"Last, First14",Not Found
"Last, First15",Not Found
"Last, First16",Not Found
"Last, First17",Not Found
"Last, First18",Not Found
"Last, First19",Not Found
"Last, First20",Not Found
"Last, First21",Not Found
"Last, First22",Not Found
"Last, First23",Not Found
"Last, First24",Not Found
"Last, First25",Not Found
"Last, First26",Not Found
"Last, First27",Not Found
"Last, First28",Not Found
"Last, First29",Not Found
"Last, First30",Not Found
"Last, First31",Not Found
"Last, First32",Not Found
"Last, First33",Not Found
"Last, First34",Not Found
"Last, First35",Not Found
"Last, First36",Not Found
"Last, First37",Not Found
"Last, First38",Not Found
"Last, First39",Not Found
"Last, First40",Not Found
"Last, First41",Not Found
"Last, First42",Not Found
"Last, First43",Not Found
"Last, First44",Not Found
"Last, First45",Not Found
"Last, First46",Not Found
"Last, First47",Not Found
"Last, First48",Not Found
"Last, First49",Not Found
"Last, First50",Not Found
"Last, First51",Not Found
"Last, First52",Not Found
"Last, First53",Not Found
"Last, First54",Not Found
"Last, First55",Not Found
"Last, First56",Not Found
"Last, First57",Not Found
"Last, First58",Not Found
"Last, First59",Not Found
"Last, First60",Not Found
"Last, First61",Not Found
"Last, First62",Not Found
"Last, First63",Not Found
"Last, First64",Not Found
"Last, First65",Not Found
"Last, First66",Not Found
"Last, First67",Not Found
"Last, First68",Not Found
"Last, First69",Not Found
"Last, First70",Not Found
"Last, First71",Not Found
"Last, First72",Not Found
"Last, First73",Not Found
"Last, First74",Not Found
"Last, First75",Not Found
"Last, First76",Not Found
"Last, First77",Not Found
"Last, First78",Not Found
"Last, First79",Not Found
"Last, First80",Not Found
"Last, First81",Not Found
"Last, First82",Not Found
"Last, First83",Not Found
"Last, First84",Not Found
"Last, First85",Not Found
"Last, First86",Not Found
"Last, First87",Not Found
"Last, First88",Not Found
"Last, First89",Not Found
"Last, First90",Not Found
"Last, First91",Not Found
"Last, First92",Not Found
"Last, First93",Not Found
"Last, First94",Not Found
"Last, First95",Not Found
"Last, First96",Not Found
"Last, First97",Not Found
"Last, First98",Not Found
"Last, First99",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 51",IR96639
"Last, First 31",IR91375
"Last, First 44",IR85788
"Last, First 35",IR81662
"Last, First 45",IR74775
"Last, First 36",IR56242
"Last, First 43",IR56242
"Last, First 46",IR56242
"Last, First 48",IR56242
"Last, First 55",IR56242
"Dux, Frank",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 70",IR56242
"Last, First 50",IR44372
"Last, First 33",IR42115
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 32",IR29068
"Last, First 40",IR27733
"Last, First 49",IR243582
"Last, First 37",IR243581
"Last, First 54",IR242063
"Last, First 53",IR241815
"Last, First 38",IR218205
"Last, First 57",IR217930
"Last, First 39",IR215508
"Last, First 41",IR195806
"Last, First 30",IR178156
"Last, First 34",IR171053
"Last, First 52",IR170923
"Last, First 42",IR130915
"Last, First 40",IR117714
"@
$auditSample = Import-Csv .\auditSample.csv
$auditSample | Group-Object -Property IRNumber -NoElement | Sort-Object -Property Count -Descending

Count Name
----- ----
99 Not Found
18 IR56242
12 IR29068
10 Service Account
9 Local Admin Account
3 Domain Admin
1 IR241815
1 IR215508
1 IR218205
1 IR217930
1 IR195806
1 IR130915
1 IR117714
1 IR170923
1 IR178156
1 IR171053
1 IR242063
1 IR81662
1 IR74775
1 IR85788
1 IR96639
1 IR91375
1 IR243582
1 IR243581
1 IR27733
1 IR44372
1 IR42115

Looking to get:

Count Name
----- ----
99 Not Found
18 IR56242
12 IR29068
10 Service Account
9 Local Admin Account
3 Domain Admin
20 Unique IR

Thanks again