Login Register






[Powershell] List all processes with CPU usage, and filepaths filter_list
Author
Message
[Powershell] List all processes with CPU usage, and filepaths #1
Screenshot:
[Image: ibivczPpoRRXgL.png]

Code:
function List_Processes { write-host; $_date = get-date -format F $proc_num = 0 $_s = { write-host "Running Processes Information -" $_date -foregroundcolor "cyan"; write-host $running = ps | sort-object cpu -descending $running | %{ foreach ($obj in $_) { $proc_num++ $num = "[" + $proc_num + "]" write-host "$num " -nonewline; write-host $obj.Name -foregroundcolor "magenta" -nonewline; write-host " - " -nonewline; write-host "PID:" $obj.ID -foregroundcolor "cyan" if ($obj.CPU) { write-host "-- CPU:" $obj.CPU write-host "-- Location:" $obj.Path } write-host } } write-host "----------------------------------------------" write-host $proc_num "Total Running Processes" -foregroundcolor "cyan" } write-host "Script Completion Time:" (measure-command -Expression $_s ).Milliseconds "milliseconds" -foregroundcolor "cyan"; write-host "----------------------------------------------"; write-host } List_Processes

Here's another powershell function i've scripted and put into use. What my script does, is it creates a list of processes and sorts them out by CPU usage, with processes at the top being the most CPU reliant, and processes at the bottom being the least CPU reliant.

Each process returned also returns it's filepath to the location where the process is executed, along with the process name, and process ID.

At the bottom of my script you see a returned value for number of processes currently running, and the time taken to produce the array/list or processes with these statistics.

Enjoy Smile
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: [Powershell] List all processes with CPU usage, and filepaths #2
Awesome script! I outta try to make something like that to get the file path by process name in au3 too... Powershell is cooler than i expected <3

Keep on posting ^_^
Pierce the life fibers with your drill.

Reply

RE: [Powershell] List all processes with CPU usage, and filepaths #3
Here's one to export process information into completely sized out columns and an organized display for a text file:

Code:
$Process = @{Expression={$_.Name};Label="Process Name";width=30}, ` @{Expression={$_.ID};Label="Process ID";width=20}, ` @{Expression={$_.CPU};Label="CPU Usage";width=30} $Proc = Get-Process | Format-Table $Process | Out-File -Filepath Output_Proc_List.txt
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply