I've been putting together a pretty simple script to monitor some aspects of our Terminal Server farm usage and am implementing a section where I check the memory usage on the servers at a given point in time. Here is the particular section that I am using to get that:

<#Modified to troubleshoot this particular section; defined $TermSvr and pipe output directly to   
$RemoteSvr = "Win10Test"

#Check current Memory Usage and Available Space
$SysMem = Get-WmiObject Win32_OperatingSystem -ComputerName $RemoteSvr
"$RemoteSvr has {0:#.0} GB free space out of {1:#.0} GB total available memory" -f   
($SysMem.TotalVisibleMemorySize/1GB) | Write-Host

This outputs:

Win10Test has **.0** GB free space out of **.0** GB total available memory

But; when I change the ($_.SysMem.TotalVisibleMemorySize/1GB) to ($_.SysMem.TotalVisibleMemorySize/1MB)

It outputs:

Win10Test has 1.1 GB free space out of 3.8 GB total available memory

Which is correct. But I feel like I'm taking crazy pills at this point. Am I missing something simple here to explain why these are only returning the value which translates into MEGABYTES of memory as opposed to the actual GIGABYTES of memory I have on the systems?

I have tried running this script against:

  • Windows 8.1
  • Windows 10 (Tech Preview)
  • Windows Server 2012 R2

Always the same outcome.


1 Answer 1


According to Win32_OperatingSystem class on MSDN:

Data type: uint64
Access type: Read-only
Total amount, in kilobytes, of physical memory available to the operating system.

Of course the same is true for FreePhysicalMemory.

Dividing by 1GB in PowerShell is the equivalent of dividing by 1073741824 (or by 1024*1024*1024). Hence, the amount of memory would need to be expressed in bytes in order for division by 1GB to return an amount of RAM in GB.

Since TotalVisibleMemorySize is in kilobytes, you can convert to GB by:



  • 2
    +1 Both FreePhysicalMemory and TotalVisibleMemorySize are in kilobytes. Could always take the long way around: $SysMem.FreePhysicalMemory * 1KB / 1GB
    – jscott
    Commented Feb 18, 2015 at 20:16
  • Yup. I had that MSDN page open on my browser the whole time and just did not read that it was output in Kilobytes. It was literally the very first line in the .TotalVisibleMemorySize description. Thanks for confirming my sanity. Commented Feb 18, 2015 at 21:08
  • So it seems Microsoft has finally come to terms with 640K not being enough RAM for everybody. ...sorry Bill. Commented Feb 18, 2015 at 21:35
  • @Twisty - sending Bill a strongly worded email about it. :P Commented Feb 19, 2015 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .