PowerShell Get-Process¶
Get-Process is a PowerShell cmdlet used to retrieve the list of running processes on the local or remote computers^[600-developer-learn-powershell01.md].
Syntax and Parameters¶
The cmdlet allows filtering processes by specific attributes using the -Name or -ID parameters^[600-developer-learn-powershell01.md].
- Get-Process -Name: Retrieves specific processes by their name^[600-developer-learn-powershell01.md].
- Get-Process -ID: Retrieves a specific process by its Process ID (PID)^[600-developer-learn-powershell01.md].
Output and Object Properties¶
By default, Get-Process returns objects that display standard properties such as Handles, NPM(K), PM(K), WS(K), VM(M), CPU(s), Id, and ProcessName^[600-developer-learn-powershell01.md]. However, the output objects contain many more properties than shown in the default table view^[600-developer-learn-powershell01.md].
To view all available properties for a specific process object, you can pipe the result to Select-Object *^[600-developer-learn-powershell01.md].
Common properties include: * Name: The name of the process^[600-developer-learn-powershell01.md]. * Id: The unique Process ID^[600-developer-learn-powershell01.md]. * Handles: The number of handles the process has opened^[600-developer-learn-powershell01.md]. * Memory Metrics: Properties like PM (Page Memory), WS (Working Set), VM (Virtual Memory), and NPM (Non-Paged Memory)^[600-developer-learn-powershell01.md]. * Threads: A collection of thread IDs associated with the process^[600-developer-learn-powershell01.md].
You can also access the .StartInfo property of a process object to inspect details such as environment variables^[600-developer-learn-powershell01.md].
Formatting Output¶
PowerShell allows you to manipulate how the process data is displayed using formatting cmdlets^[600-developer-learn-powershell01.md].
- Format-List: Displays output as a list, which is useful for viewing properties that contain multiple values, such as the
Threadscollection^[600-developer-learn-powershell01.md]. - Format-Table: Displays output in a tabular format^[600-developer-learn-powershell01.md].
When using Format-Table, the -AutoSize parameter can be added to adjust column sizes based on the actual data width^[600-developer-learn-powershell01.md].
Sorting and Filtering¶
To analyze system resources, you can combine Get-Process with sorting cmdlets^[600-developer-learn-powershell01.md]. For example, to identify which processes are consuming the most memory, you can pipe the output toSort-Objectusing the-Property PM(Page Memory) parameter and the-Descending` switch^[600-developer-learn-powershell01.md].
Sources¶
600-developer-learn-powershell01.md