Replicate Task Manager into Powershell Output

Replicate Task Manager into Powershell Output

I am new in windows powershell. I want to replicate task manager Process GUI information into excel continuously for every 5 min. Can it be possible ?

2

1 Answer

You are probably looking for the Get-Process cmdlet and Task Scheduler.

try the following:

Get-Process | Select Handles,NPM,PM,WS,CPU,Id,SI,ProcessName,@{Name = 'Timestamp'; Expression = ({(Get-Date)})} | Export-Csv -Path C:\Junk\Processes.csv -Append

If you save this into a .ps1 file, you can then call it with a scheduled task and repeat the task every 5 minutes:

Alternatively - you can use a PowerShell Loop and leave the script running in a window for as long as you need it to:

do {
    Get-Process | Select Handles,NPM,PM,WS,CPU,Id,SI,ProcessName,@{Name = 'Timestamp'; Expression = ({(Get-Date)})} | Export-Csv -Path C:\Junk\Processes.csv -Append
    start-sleep -Seconds 300
} while ($true -eq $true)

(in this case - 300 seconds is 5 minutes!)

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.