2013 PowerShell Scripting Games Advanced Event 2 – Why NOT to use the Win32_ComputerSystem WMI Class

The majority of the entries I’ve seen for the Scripting Games event 2 are using the TotalPhysicalMemory property from the Win32_ComputerSystem WMI class to determine the total amount of physical memory in a server. The property name is “TotalPhysicalMemory” after all so that’s what it should contain, right? Not so fast, keep reading to discover why.

Your manager needs an inventory of all of your company’s physical servers that are located in three different data centers which are in different parts of the country. He has assigned you the task of inventorying those servers and wants you to physically log into each server or travel to the location where the servers reside to retrieve the information using the GUI.

You’ve asked your manager if you could try retrieving this information with PowerShell first. He is skeptical and thinks PowerShell is some kind of Witchcraft Voodoo stuff that must be like EverQuest or WarCraft because people stay up late at night playing some sort of scripting games with it. Reluctantly, he gives you the go ahead to proceed with the use of PowerShell for this project. This is your chance to sell your manager on using PowerShell at your company!

The requirements that your manager wants just happens to be the same as the Scripting Games event 2 requirements. Since you’re new to PowerShell, you decide to look at the scripts that were submitted in the advanced event #2 and use the method to retrieve the information that most others used, after all, if most people used it and received good scores, then it must be right? You think “This will be too easy, I can copy one of those 5 star scripts and I’ll be the PowerShell hero at my company!”

Well, it just so happens that your company got a good deal on some servers several years ago, before you started with the company, that had 8 gigabytes of RAM in them, but due to application compatibility requirements the prior IT engineers who are no longer with the company had to load an x86 (32 bit) version Windows Server 2003 R2. The company already owned Standard Edition of that OS and they didn’t need more than 4 gigabytes of RAM so they loaded that operating system to keep the project within budget.

The awesome 5 star script that you downloaded used what most others in the competition used to retrieve the total amount of physical memory in the servers (TotalPhysicalMemory property from the Win32_ComputerSystem WMI class).

Here are the requirements your manager provided which just happen to be exactly the same as the requirements in the Scripting Games advanced event #2. As you can see, in black and white, he wants the “Amount of Installed Physical Memory” from the servers:


You’ve completed the task, turned in your amazing results to your manager and saved the company lots of money on labor and travel in the process. Now your manager wants to see you in his office. It must to be because he wants to give you a raise or promotion for doing such an awesome job!

Your manager has checked the manufacturers website for some of the servers you provided the inventory for and he wants to know who stole memory out of the servers to put in their gaming machines at home to play these scripting games because the report shows 4GB of RAM and the manufacturers website shows they shipped with 8GB.

Well, it just so happens that the 5 star script you copied as well as what most of the others are using for the Scripting Games in event #2 to retrieve the Amount of Installed Physical Memory is incorrect! What? Sorry, but it’s true.

As you can see in the image below, the TotalPhysicalMemory property of Win32_ComputerSystem WMI class only shows the amount of memory that the OS has available to it and not the amount of physical memory in the servers:


Since the Windows Server 2003 R2 Standard Edition x86 (32 bit) operating system is only able to access 4 gigabytes of RAM, that’s what the report you turned into your manager had on it, where as you can see using the Win32_PhysicalMemory WMI class and adding up or summing the capacity for all of the memory chips did indeed retrieve the actual amount of physical memory in the server.

Want to know why not to use the Win32_ComputerSystem WMI class for the number of processor sockets? See my blog titled “2013 PowerShell Scripting Games Advanced Event 2 – Attention to Detail is Everything

Want to see my solution for Scripting Games advanced event 2? Click this link: Advanced 2: An Inventory Intervention: http://scriptinggames.org/entrylist.php?entryid=552. You’ll have to be signed in to see the solution. If you like my script, please vote for it! Click on the star all the way to the right:


Update 02/09/14
The link to my solution is no longer valid so I’m posting it here since I’ve received some requests for it:

This PowerShell script can also be downloaded from the TechNet script repository.



  1. Matt Tilford

    A very nice post explaining why using capacity is better than totalphysicalmemory. I would have to comment though that while testing scripts from the games i found capacity to be wrong on my computer. It reports the original amount of RAM i had in my computer (4x512MB) rather than it’s current (4x1024MB).

    That might just be some craziness of WMI on my computer but it does suggest that those values may not be entirely reliable too. Wouldn’t want the boss questioning where that 48GB upgrade kit went instead of into the servers!

  2. pamkkkkk

    Good Article!
    But this is a fault of microsoft not to the scripters!
    Im many cases microsoft has to many ways for the same thing. And we have the fun to fiddel out the correct way. (Like Snake Plissken (Curt Russel)) trough the mine field.
    What are both reporting if you have Hyper-V or other Virtual voodo on?

    my 50 cent….


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: