Hello,
I'm trying to build a powershell script that returns all the process
the are currently taking up more then 1% of CPU use. I got the script
running, the everytime I execute it, it always returns the same
process with the same percentual value for each. What am I doing
wrong? Here's the script
$procs_total = gwmi -Class Win32_PerfRawData_PerfProc_Process -Filter
'name="_total"';
$procs = gwmi -Class Win32_PerfRawData_PerfProc_Process -Filter
'name<>"_total"';
[int64]$totalpercentuser = 0;
foreach ($proc in $procs_total)
{$totalpercentuser = $totalpercentuser + $proc.PercentUserTime};
[decimal] $perc = [System.Convert]::ToDecimal($totalpercentuser);
foreach ($proc in $procs)
{$proc_perct = (($proc.PercentUserTime / $perc) * 100);
if ($proc_perct -gt 1){
$proc_perct.ToString() + ' - Name: ' + $proc.Name;};
} ;
Thanks


