Checking CPU utilization
One of the best ways to monitor CPU utilization with PowerShell is by querying performance counters. We can also get this information using WMI. In this recipe, you'll learn a few techniques that can be used to monitor CPU utilization using the Get-Counter
and Get-WmiObject
cmdlets.
How to do it...
- To get an idea of the current CPU utilization for a server, we can gather data for the
Processor(_Total)\% Processor Time
performance counter:Get-Counter "\Processor(_Total)\% Processor Time" -Continuous
This would continuously output the total utilization across each CPU, as shown:
- In addition, we can use the
Win32_Processor
class ...
Get Microsoft Exchange 2010 PowerShell Cookbook 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.