Monitoring memory utilization
To retrieve memory information from local and remote computers using PowerShell, we can use WMI, or query performance counters. In this recipe, you'll learn a few techniques that can be used to monitor memory utilization using the Get-WmiObject
cmdlet.
How to do it...
- To gather memory utilization with WMI, we need to query two separate classes:
$OS = Get-WmiObject Win32_OperatingSystem $CS = Get-WmiObject Win32_ComputerSystem
- Next, we can access the free and total physical memory from each object:
- To convert the values to gigabytes, we need to use the
mb
andgb
multipliers:
Now we can easily see that the local system has ...
Get Microsoft Exchange Server 2013 PowerShell Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.