PS Group-Object Feature

Hello community

I’m wondering if is there any cool way-tip to group some objects by property of time range.
Guess that we have eventlog objects and we want to group them by time range of one hour

Something like the following:
For example starting from 00:00 “hour”:
Name Value

01:00 10
02:00 5
03:00 15
04:00 20
05:00 14


Thank you in advance!!!

You said it right in your post title! Group-Object!

For event logs, to group by hour, you can do something like this:

Get-EventLog -LogName Application -Newest 1000 | Group-Object -Property {$_.TimeWritten.Hour}

Absolutely, but first you have to generate a property with that value to group by (or use a constructed property in the call to Group-Object). Assuming that the objects you want to group have a property named “DateTime”, which is a DateTime object, that might look something like this:

$objects |
Group-Object -Property { '{0:D2}:00' -f $_.DateTime.Hour }

Thank you very much!!!

This really helped !!!