r/PowerShell • u/GonzoZH • Jan 05 '26
Get-WorkTime: Simple PowerShell module to summarize work time from Windows event logs
Hi PowerShellers,
Maybe it is useful for others as well:
Since I track my work time, I often can’t remember on Friday how I actually worked on Monday, so I needed a small helper.
Because my work time correlates pretty well with my company notebook’s on-time, I put together a small PowerShell module called Get-WorkTime.
It reads boot, wake, shutdown, sleep, and hibernate events from the Windows System event log and turns them into simple daily summaries (start time, end time, total uptime). There’s also an optional detailed view if you want to see individual sessions.
In case of crashes, it uses the last available event time and marks the inferred end time with a *. The output consists of plain PowerShell objects, so it’s easy to pipe into CSV or do further processing.
The code is on GitHub here: https://github.com/zh54321/Get-WorkTime
Feedback or suggestions are welcome.
Cheers
View all comments
Show parent comment
1
u/GonzoZH Jan 05 '26
Thank you for the input, that is a very good point.
Using logon, lock, and unlock events can definitely make more sense in organizations where uptime does not reflect actual user activity.
However, there is probably no one-size-fits-all solution. There are many edge cases, such as locking a computer during meetings, not locking it and relying on auto-lock after some idle time, machines being left on all day, travel time between customer sites etc.
This script is just a simple and basic approach and is just one possible interpretation of work time. How well it fits depends heavily on the actual requirements and on how work time is defined in a given environment.