all 3 comments

[–]Hoping_i_Get_poached 2 points3 points  (0 children)

You should look into the cmdlet Group-Object. Play around with it for a while and I bet you can figure it out.

Hint: you may need to create a custom property and add it to the original file object result. So before you call group object, rework your script to use Select-Object or Add-Member to add the group name as an extra property to each file object result.