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...

  1. To get an idea of the current CPU utilization for a server, we can gather data for the Processor(_Total)\% ProcessorTime performance counter:
    Get-Counter "\Processor(_Total)\% Processor Time" -Continuous
    

    This would continuously output the total utilization across each CPU, as shown:

    How to do it...
  2. In addition, we can use the Win32_Processor

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.