Listing processes

In this recipe, we will list processes in the system.

How to do it...

Let's list processes using PowerShell:

  1. Open PowerShell ISE as an administrator.
  2. 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
  3. 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
  4. Add the following script and run it to save the processes to a CSV file:
    #save ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.