Category Archives: Scripting

Where Did the Time Go?

antique watchLike many of you the work day just seems to fly by. At the end of the day I start wondering what I really got accomplished and what I actually did all day. Well if you are willing to face the truth I have a way to help. Last year I wrote about a PowerShell module I called MyMonitor. As part of my ongoing effort to make some of my larger projects more accessible, I have revised it and published to GitHub.

The MyMonitor module works under the premise of keeping track of what window is currently active and how long it has been running. I can also extract other information using Get-Process that indicates the window title, the associated product, when the process started and when it ended. I include the processID as well, although that probably doesn’t have any practical value.

The data collection process starts with Get-WindowTime. You can specify a time duration in minutes such as 60 minutes. Or perhaps you want to collect your usage data until 4:00PM. You can do that as well. One way that I use the command is with the ProcessName parameter. The concept is that you can start an application that you rarely use. When Get-WindowTime detects the process, it terminates collection. I typically use Windows Calculator as a “flag” process. Finally, you can run all of this as a background job so that you can get your PowerShell prompt back. Just don’t close your session before you stop the job and collect the data.

The new version also includes categories. I created an XML file in the module with categories for different applications. You can have an application with more than one category. This adds another way to see where you are spending your time. More on that in a moment. When you collect your usage statistics, you’ll get an object like this for each application.

data sample

The module includes a few cmdlets for reporting and analyzing the data.

Getting a summary report

Or you can use Measure-WindowTotal to slice and dice the data.

Measuring window time by application

Measuring window time by category

You can even get a bit more granular be filtering on text in window titles.

Measuring time by window title (Image Credit: Jeff Hicks)

All of the commands in the module have complete help and examples. There is also an About topic.


The module is still a work in project. One of the items on the wish list is a better way to archive usage. This would allow you get a better idea of where your time goes on a weekly or monthly basis.

But for now, you can get the module source files from the repository on GitHub. I strongly recommend you read the About topic and help before you start using the module. Comments are welcome here but please use GitHub to report any problems or feature requests.

Hyper-V Memory Utilization with PowerShell

I really push the limits of my Hyper-V setup. I know I am constrained by memory and am hoping to expand my network before the end of the year. But in the meantime I have to keep close tabs on memory. I thought I’d share a few commands with you. I am assuming you have the Hyper-V module installed locally. You don’t have to be running a hypervisor in order to use the PowerShell commands to manage a remote server. Or you can take my commands and run them remotely via a PSSession or Invoke-Command.

First off, I only need to get virtual machines that are currently running.

This command is using the newer Where-Object syntax. Here’s a sample result.

Memory usage for running VMs

Or I can use the newer Where() method in v4 which performs better. I’ll get the same result.

The memory values are in bytes which I’m never good at reformatting in my head, so I’ll PowerShell do the work.

Formatted values

You know what? I want to take this a step further, which is usually my inclination. I think it would be useful to also see what percentage of assigned memory is being demanded. I can calculate this percentage and round to 2 decimal places.

Memory utilization with percentage

That should give me all of the data I need. The last step is to format the results into an easy to read report.

Formatted VM memory report

I can take this code and turn it into a script or function to save some typing. Perhaps even parameterize for the computername. I have some other thoughts as well which I hope I can get to at some point. But for now clearly I have some issues on my Hyper-V server, CHI-HVR2, to attend to.


My Uptime PowerShell Module Published to GitHub

Earlier this year I wrote a PowerShell module to get uptime information. The module was part of a series I wrote for As part of my ongoing project to move some of my more interesting, and hopefully useful, tools to GitHub, I revised the module. The new version makes better use of custom format and type extensions, including the addition of several methods.

You can also now use a CIMSession instead of a computername and the results are “live”. Because I defined some script properties, uptime values are updated every time you view the object. I will be writing about the changes in more detail on But for now, you can find the module on GitHub. I hope you’ll let me know what you think and what would make it even better.