i want a script to capture the current CPU usage for every process above 0 CPU usage.
i create this script but i see that the script doesn’t report a right CPU usage like task manager show because it doesn’t calculated the processor threads so i show 99 CPU usage. i found this code that show the CPU count [System.Environment]::ProcessorCount
my question is how do i insert the code into the cookedvalue results that it will reflect like task manager?
Get-Counter ‘\Process(*)\% Processor Time’ | Select-Object -ExpandProperty countersamples | Select-Object -Property instancename, cookedvalue| where {$_.instancename -ne “_Total” -and $_.instancename -ne “Idle” -and $_.cookedvalue -gt 0} | Sort-Object -Property cookedvalue -Descending | ft -AutoSize
THX