CPU and memory usage in percentage for all processes in Powershell
<p>Is there a way for viewing CPU and memory utilization in percentage for all running processes in <code>PowerShell</code>?</p>

<p>I have tried the following:</p>

<pre><code>Get-Process | %{"Process={0} CPU_Usage={1} Memory_Usage={2}" -f $_.ProcessName,[math]::Round($_.CPU),[math]::Round($_.PM/1MB)}
</code></pre>

<p>Along with it I have parsed this information and calculated memory usage percentage from total memory, but couldn't get the same for CPU since by this command it show CPU time division in processes not utilization per se.</p>

<p>Used the following commands for total memory and total cpu utilization:</p>

<ol>
<li><p>TOTAL PHYSICAL MEMORY</p>

<p><code>Get-WmiObject Win32_OperatingSystem | %{"{0}" -f $_.totalvisiblememorysize}</code></p></li>
<li><p>TOTAL CPU UTILIZATION</p>

<p><code>Get-WmiObject Win32_Processor | Select-Object -expand LoadPercentage</code></p></li>
</ol>

<p>Any help would be appreciated. I need it in the following format:</p>

<pre><code>PROCESS=process_name CPU=percent_cpu_utilization_by_process MEMORY=percent_memory_utilization_by_process
</code></pre>