Questions tagged [group-object]

For questions related to PowerShell's Group-Object cmdlet.

See Group-Object.

20 questions
3
votes
2 answers

Group-Object, get counts

Given a list with some duplicate items, I can use Group-Object -AsHashtable and I get a hash table that seems to have keys with the item names, and the value is something I don't recognize. So, given $array =…
Gordon
  • 6,257
  • 6
  • 36
  • 89
3
votes
1 answer

Group-Object AsHashTable doesn't work for ScriptProperty

Works: $Names = 1..5 | % { new-object psobject | add-member -Type NoteProperty -Name Name -Value "MyName" -PassThru } | group Name -AsHashTable $Names.MyName Doesn't work: $Names = 1..5 | % { new-object psobject | add-member -Type ScriptProperty…
xinglong
  • 115
  • 1
  • 5
2
votes
1 answer

PowerShell - Group-Object Poor Performance

I've written a script to help me identify duplicate files. For some reason if I split these commands and export/import to CSV it runs much faster than if I leave everything in memory. Here is my original code, it is god-awful slow: Get-ChildItem M:\…
TJ O
  • 25
  • 3
2
votes
1 answer

PowerShell Group-Object no longer splitting objects into fixed-size collections

I had this in a script which I believe was working well, but appears to have stopped working: $testList = @("object 1","object 2","object 3","object 4","object 5") $counter = 0 $maxSize = 2 $groupedList = $testList | Group-Object {…
Dicky Moore
  • 956
  • 3
  • 10
  • 32
2
votes
1 answer

PowerShell: Import CSV File, Count Group Sizes, And Output To Original File Appending New Column With Counts

I have a test input csv file, as follows: ID;Name;Level 1;Alpha;A 2;Bravo;A 3;Charlie;A 4;Delta;A 5;Echo;A 6;Foxtrot;A 7;Golf;A 1;Hotel;B 2;India;B 3;Juliet;B 1;Kilo;C 2;Lima;C 3;Mike;C 4;November;C 5;Oscar;C and I would like to generate the…
matekus
  • 778
  • 3
  • 14
1
vote
1 answer

Find multiple of the same objects in an Array and do something with these objects

I need a PowerShell-Script that does the following: Get the AD-Groupmember of six different AD-Groups. Show only members who are in more than two of those AD-Groups. Remove these members from those AD-Groups. I could only come up with a Script,…
1
vote
1 answer

how to count split words select-string pattern powershell. text file log life .txt .log

I need to count rows with values ms 2xx (where xx is any number) it can be 200,201,202,258,269 etc. (It has to start with number 2) Then do it also with numbers 4 and 5. There In my .txt file with rows like this: 2022.10.20 13:42:01.570 | INFO |…
Gaara
  • 39
  • 5
1
vote
1 answer

Retrieve S3 filenames, group by 3 digit number with related images in series then split series into columns and new group into new row

I'm attempting to use a CSV to bulk upload listings however the image urls are in columns. I'm using Amazon S3 to host the images and PowerShell to retrieve the keys of each file. However I am unsure how to group by their related files and then use…
1
vote
2 answers

Powershell -Rename files from "Group-Object" output

So I have 150 folders with 100's of files named like…
1
vote
1 answer

Powershell Performance tuning for aggregation operation on big delimited files

I have a delimited file with 350 columns. The delimiter is \034(Field separator). I have to extract a particular column value and find out the count of each distinct value of that column in the file. If the count of distinct value is greater or…
TomG
  • 281
  • 1
  • 2
  • 20
1
vote
1 answer

Data manipulation\deduplication in powershell

Hey I am looking to deduplicate some data and combine columns from a CSV. Can't get my head around how to do it. Here is a sample of the data I am working with: cmmc,stig,descr AC.1.001,SV-205663r569188_rule,The ability to set access permissions and…
1
vote
1 answer

PowerShell. Group-object usage in one file

I am trying to combine several rows into one, provided that the key cell is the same. And write data from all lines with the same key to the final line. Example Pic **Before** ID | Name | DateTime | Duration | Call_Type …
0
votes
1 answer

PowerShell ForEach-Object Only Matching first Value passed

I am writing a PowerShell script that reads a CSV file in the following…
0
votes
0 answers

Group Objects within already grouped objects

I'm trying to prepare a list of files with duplicate names but different extensions. At the same time I'd like to exclude files with the same extension. So far I've created this gci -path "PATH" -recurse -file -erroraction silentlycontinue| Select…
Nawad-sama
  • 151
  • 2
  • 12
1
2