I know I could just use perfmon but I wonder whether there would be an easy Powershell way to find what process on my server is the most CPU intensive over a whole day? This would require finding out which hit the maximum usage but this wouldn’t give a lear overall picture so also the same one was the greatest CPU user in total during the period? Would probing get-process be a good approach here?
You have to setup some sort of data collector for this.
The OS doesn’t store performance information over time by default.
The best way is to use something like perfmon, SCOM or other monitoring tools to gather the data.
Of course you could use powershell together with e.g. perfmon to collect/query the performance information.
You have cmdlets for it like Get-Counter.
There are a number of articles about it out there, just search for “perfmon” “powershell”.
Take a look at this article.
ps | sort -Descending cpu | select -first 1