So you need to check how much RAM is available on your Windows machine, and you want to do it using PowerShell. Maybe your computer is running slow, or you’re troubleshooting a server, or you just want to keep tabs on memory usage.
Whatever the reason, I’ve got you covered.
In this tutorial, I’ll show you exactly how to get free memory information using PowerShell. I’ll walk you through multiple methods, explain what each command does, and give you practical examples you can use right away.
Let’s jump in.
Why Check Free Memory in PowerShell?
Before we get into the how, let me quickly touch on the why.
Checking free memory helps you:
- Figure out if your computer has enough RAM to run applications smoothly
- Troubleshoot performance issues (slow apps often mean low memory)
- Monitor servers remotely without needing a GUI
- Create scripts that automatically alert you when memory runs low
- Make informed decisions about whether you need a RAM upgrade
PowerShell gives you way more control and detail than just opening Task Manager. Plus, you can automate it.
Method 1: Using Get-CimInstance (The Modern Way)
This is my go-to method. It’s the most current approach and works on Windows 10, Windows 11, and Windows Server 2016 and newer.
Here’s the basic command:
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object FreePhysicalMemory, TotalVisibleMemorySizeWhen you run this, you’ll see something like:
FreePhysicalMemory TotalVisibleMemorySize
------------------ ----------------------
1924260 16437444You can see the exact output in the screenshot below:

The numbers you see are in kilobytes (KB). Not gigabytes. Keep that in mind.
- FreePhysicalMemory: The amount of RAM currently available
- TotalVisibleMemorySize: The total amount of RAM in your system
Converting to Gigabytes
Nobody thinks in kilobytes anymore. Let’s convert this to gigabytes so it actually makes sense:
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$freeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
$totalMemoryGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
Write-Host "Free Memory: $freeMemoryGB GB"
Write-Host "Total Memory: $totalMemoryGB GB"This gives you a clean output like:
Free Memory: 1.99 GB
Total Memory: 15.68 GBYou can see the exact output in the screenshot below:

Much better, right?
Breaking Down the Code
Let me explain what’s happening here:
$os = Get-CimInstance...stores the memory information in a variable/ 1MBconverts kilobytes to megabytes, then to gigabytes[math]::Round(..., 2)rounds the number to 2 decimal placesWrite-Hostdisplays the results in a readable format
Check out How to Enable BitLocker with PowerShell?
Method 2: Using Get-WmiObject (The Old Reliable)
If you’re working with older Windows systems (like Windows 7 or Server 2012), you might need to use Get-WmiObject instead.
Get-WmiObject -Class Win32_OperatingSystem | Select-Object FreePhysicalMemory, TotalVisibleMemorySizeThis does the same thing as Get-CimInstance. The output looks identical.
Here’s the same conversion to gigabytes:
$os = Get-WmiObject -Class Win32_OperatingSystem
$freeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
$totalMemoryGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
Write-Host "Free Memory: $freeMemoryGB GB"
Write-Host "Total Memory: $totalMemoryGB GB"Here is the exact output in the screenshot below:

Note: Microsoft is phasing out WMI cmdlets in favor of CIM cmdlets. If your system supports Get-CimInstance, use that instead.
Read PowerShell Get-WindowsAutoPilotInfo
Method 3: Getting More Detailed Information
Sometimes you want more than just free memory. You want the whole picture.
Here’s a command that gives you everything:
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$totalMemory = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
$freeMemory = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
$usedMemory = $totalMemory - $freeMemory
$percentFree = [math]::Round(($freeMemory / $totalMemory) * 100, 2)
Write-Host "Total Memory: $totalMemory GB"
Write-Host "Used Memory: $usedMemory GB"
Write-Host "Free Memory: $freeMemory GB"
Write-Host "Percentage Free: $percentFree%"This gives you output like:
Total Memory: 16.23 GB
Used Memory: 12.14 GB
Free Memory: 4.09 GB
Percentage Free: 25.2%Now you can see exactly how much memory is being used and what percentage is still available.
Method 4: Checking Memory on Remote Computers
One of the best things about PowerShell is that you can check memory on other computers without physically being there.
Here’s how:
$computerName = "SERVER01"
$os = Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $computerName
$freeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
Write-Host "Free Memory on $computerName : $freeMemoryGB GB"Just replace “SERVER01” with the actual computer name or IP address.
Requirements for remote access:
- You need administrator rights on the remote computer
- Windows Remote Management (WinRM) needs to be enabled
- The remote computer must be on the same network or accessible via VPN
Check out Find OU of a Computer Using PowerShell
Create a Reusable Function
If you’re going to check memory regularly, why not create a function you can call anytime?
Here’s a handy function you can save and reuse:
function Get-FreeMemory {
param(
[string]$ComputerName = $env:COMPUTERNAME
)
$os = Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName
$totalMemory = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
$freeMemory = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
$usedMemory = $totalMemory - $freeMemory
$percentFree = [math]::Round(($freeMemory / $totalMemory) * 100, 2)
[PSCustomObject]@{
ComputerName = $ComputerName
TotalMemoryGB = $totalMemory
UsedMemoryGB = $usedMemory
FreeMemoryGB = $freeMemory
PercentFree = $percentFree
}
}Now you can simply run:
Get-FreeMemoryOr check a remote computer:
Get-FreeMemory -ComputerName "SERVER01"You can even check multiple computers at once:
"SERVER01", "SERVER02", "DESKTOP03" | ForEach-Object { Get-FreeMemory -ComputerName $_ }Check out RPC Server is Unavailable Error in PowerShell
Practical Use Cases
Let me show you a few real-world scenarios where this comes in handy.
Alert When Memory Is Low
Create a script that sends you an alert when free memory drops below a certain threshold:
$threshold = 2 # Alert if free memory is below 2 GB
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$freeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
if ($freeMemoryGB -lt $threshold) {
Write-Warning "Low memory alert! Only $freeMemoryGB GB free."
# You could send an email or notification here
}Export Memory Info to CSV
Need to document memory usage across multiple servers? Export it to a CSV file:
$computers = "SERVER01", "SERVER02", "SERVER03"
$results = @()
foreach ($computer in $computers) {
$results += Get-FreeMemory -ComputerName $computer
}
$results | Export-Csv -Path "C:\MemoryReport.csv" -NoTypeInformationMonitor Memory Over Time
Set up a scheduled task that logs memory usage every hour:
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$freeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"$timestamp, $freeMemoryGB" | Out-File -FilePath "C:\MemoryLog.txt" -AppendTroubleshooting Common Issues
“Access Denied” Error
If you get an access denied error, you probably don’t have administrator rights. Right-click PowerShell and choose “Run as Administrator.”
Remote Computer Not Accessible
If you can’t connect to a remote computer, check:
- Is WinRM enabled? Run
winrm quickconfigon the remote machine - Is there a firewall blocking the connection?
- Do you have admin rights on that machine?
- Can you ping the computer?
Numbers Look Wrong
Remember, the default output is in kilobytes, not gigabytes. Always convert to GB for easier reading.
Check out PowerShell Kill Process by Name
Quick Reference Commands
Here’s a cheat sheet of the most useful commands:
Basic free memory check:
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object FreePhysicalMemoryFree memory in GB:
[math]::Round((Get-CimInstance -ClassName Win32_OperatingSystem).FreePhysicalMemory / 1MB, 2)Complete memory information:
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object TotalVisibleMemorySize, FreePhysicalMemory, TotalVirtualMemorySize, FreeVirtualMemoryWrapping Up
There you have it. You now know how to check free memory in PowerShell using multiple methods.
Start with Get-CimInstance if you’re on a modern Windows system. Convert the values to gigabytes for easier reading. And if you need to do this regularly, create a function to save yourself time.
The beauty of PowerShell is that once you understand these basics, you can build on them. Add error handling, create reports, set up monitoring, or integrate with other scripts.
Play around with these commands. Try them on your own machine first, then explore remote management once you’re comfortable.
You may also like the following tutorials:
- PowerShell Find Location of Executable
- How to Find Ports in Use using PowerShell?
- PowerShell Find IP from MAC Address
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.