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 ?
21 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 -AppendIf 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