Listing processes
In this recipe, we will list processes in the system.
How to do it...
Let's list processes using PowerShell:
- Open PowerShell ISE as an administrator.
- Add the following script and run it to list processes on the screen:
#list all processes to screen Get-Process #list 10 most recently started processes Get-Process | Sort-Object -Property StartTime -Descending | Select-Object Name, StartTime, Path, Responding -First 10
- Add the following script and run it to list and save the processes to a text file:
#save processes to a text file $txtFile = "C:\Temp\processes.txt" Get-Process | Out-File -FilePath $txtFile -Force #display text file in notepad notepad $txtFile
- Add the following script and run it to save the processes to a CSV file:
#save processes to a csv file $csvFile = "C:\Temp\processes.csv" Get-Process | Export-Csv -Path $csvFile -Force -NoTypeInformation #display first five lines in file Get-Content $csvFile -totalCount 5
- Add the following script...