Mastery Mystery

More to come…

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.

Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.