How to do it...

As we already discussed, our goal here is to work with processes.

  1. List out the cmdlets that help you work with processes.
PS> Get-Command -Noun Process
Remember that PowerShell uses only singular nouns.

We get five cmdlets. What we initially need is Get-Process.

  1. Run the cmdlet to see what it shows.
PS> Get-Process

The output is a long table of processes, the memory they are consuming, the CPU time they are using, etc.

  1. Get the total count of processes currently running in the system.
PS> (Get-Process).Count
  1. Now, fetch the average of the pages of memory used by the processes. The term for this is Working Set, denoted as WS.
PS> Get-Process | Measure-Object -Property WS -Average
  1. There are other fields in the hash table as well. Let us get all of that information.
PS> Get-Process | Measure-Object -Property WS -Average -Sum -Minimum -Maximum
  1. Get the average, sum, minimum and maximum for both, the working set, as well as the CPU.
PS> Get-Process | Measure-Object -Property WS, CPU -Average -Sum -Minimum -Maximum
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.67.251