Get Process (Microsoft.PowerShell.Management) - PowerShell (2023)

  • Reference
Module:
Microsoft.PowerShell.Management

Gets processes running on the local computer.

Syntax

Get-Process [[-Name] <String[]>] [-Modul] [-FileVersionInfo] [<CommonParameters>]
Get-Process [[-Name] <String[]>] -IncludeUserName [<CommonParameters>]
Get-Process -Id <Int32[]> [-Modul] [-FileVersionInfo] [<CommonParameters>]
Get-Process -Id <Int32[]> -IncludeUserName [<CommonParameters>]
Get-Process -InputObject <Prozess[]> [-Modul] [-FileVersionInfo] [<CommonParameters>]
Get-Process -InputObject <Prozess[]> -IncludeUserName [<CommonParameters>]

Description

Öget processcmdlet gets the processes on a local or remote computer.

With no parameters, this cmdlet gets all processes on the local computer. You can also specify a specific process by process name, process identifier (PID), or pipe a process object to this cmdlet.

By default, this cmdlet returns a process object that contains detailed information about the process and supports methods that you can use to start and stop the process. You can also use parameters fromget processCmdlet to get information about the file version of the program running in the process and to get the modules that the process has loaded.

examples

Example 1: Get a list of all running processes on the local computer

get process

This command gets a list of all active processes running on the local computer. For a definition of each column, seeNutsSection.

Example 2: Get all available data about one or more processes

Get process winword, explorer | List of Formats *

This command retrieves all available data about Winword and Explorer processes on the computer. he uses theName-parameter to specify the processes, but omit the optional parameter name. The pipeline operator (|) passes the data to theList of FormatsCmdlet that shows all available properties (*) of the Winword and Explorer process objects.

You can also identify processes by their process IDs. For example,Get-Process-ID 664, 2060.

Example 3: Get all processes with a working set larger than a specified size

Get-Processo | Where-Object {$_.WorkingSet -gt 20000000}

This command gets all processes that have a working set greater than 20MB. he uses theget processCmdlet to get all running processes. The pipeline operator (|) passes the process objects to thewhere objectCmdlet that selects only the object with a value greater than 20,000,000 bytes for theWorkingsetProperty.

Workingsetis one of the many properties of process objects. To view all properties, typeGet-Processo | Get Member. By default, the values ​​for all set properties are in bytes, although the default view lists them in kilobytes and megabytes.

(Video) PowerShell Basics Get-Process Tutorial

Example 4: List processes on the computer in groups by priority

$A = Get-Process$A | get process | Format table -Show priority

These commands list the processes on the computer into groups based on their priority class. The first command gets all the processes on the computer and saves them in the$AVariable.

The second command channels theProceedingsObject saved in$Avariable for theget processcmdlet and then toformat tableCmdlet that formats processes usingprioritysee.

ÖpriorityView and other views are defined in PS1XML format files in the PowerShellhome directory ($pshome).

Example 5: Adding a property to the default Get-Process output view

Get-Process pwsh | format table ` @{Label = "NPM(K)"; Expression = {[int]($_.NPM / 1024)}}, @{Label = "PM(K)"; Expression = {[int]($_.PM / 1024)}}, @{Label = "WS(K)"; Expression = {[int]($_.WS / 1024)}}, @{Label = "VM(M)"; Expression = {[int]($_.VM / 1MB)}}, @{Label = "CPU(s)"; expression = {if ($_.CPU) {$_.CPU.ToString("N")}}}, ID, process name, start time -AutoSizeNPM(K) PM(K) WS(K) VM(M) CPU( s) ID Process Name Start Time------ ----- ----- ----- ------ -- ----------- ----- ---- 143 239540 259384 2366162 22.73 12720 PWSH 05/02/2022 15:21:51 114 61776 104588 2366127 11.45 18336 PWSH 12/2022 7:30:53. AM 15672424242360 23/06023.3010.3010 23.3010.3010. /2022 07:30:52 85 48216 115192 2366074 1.14 24428 pwsh 2022-12-08 09:14:15

This example restores processes from the local computer. The recovered processes are directed to theformat tableCommand that adds thestart timeproperty for the patternget processoutput display.

Example 6: Retrieving version information for a process

Get-Process pwsh -FileVersionInfoProductVersion FileVersion FileName-------------- ----------- --------6.1.2 6.1.2 C:\ Programmpakete\PowerShell\6\pwsh.exe

This command uses theFileVersionInfoParameters to get the version information for thepwsh.exeFile that is the main module for the PowerShell process.

To run this command with processes that you don't have on Windows Vista and later versions of Windows, you need to open PowerShell withExecute as administratorPossibility.

Example 7: Get modules loaded with the specified process

Get-Process SQL* -Modul

This command uses theModuleto get the modules loaded by the process. This command gets modules from processes whose names start withSQL.

To run this command on Windows Vista and later versions of Windows with processes you are not running, you must start PowerShell withExecute as administratorPossibility.

Example 8: Find the owner of a process

Get-Process pwsh -IncludeUserNameHandles WS(K)-CPU(s)-ID Benutzername Prozessname------- ----- ------ -- -------- ----- ------ 782 132080 2.08 2188 DOMAIN01\user01 pwsh

This command shows how to find the owner of a process. On Windows it isInclude usernameParameter requires elevated user rights (Execute as administrator). The output shows that is the ownerdomain01\user01.

Example 9: Use an automatic variable to identify the process hosting the current session

Get-Process pwshNPM(K) PM(M) WS(M) CPU(s) ID SI ProcessName------ ----- ----- ------ -- -- -- --------- 83 96,21 105,95 4,33 1192 10 pwsh 79 83,81 117,61 2,16 10580 10 pwshGet-Process -Id $PIDNPM(K) PM(M) WS( M) CPU(s) ID SI ProcessName--- --- ----- ----- ------ -- -- ----------- 83 96,21 77,53 4,39 1192 10 pwsh

These commands show how to use them$PIDautomatic variable to identify the process hosting the current PowerShell session. You can use this method to distinguish the host process from other PowerShell processes that you may want to kill or close.

The first command gets all PowerShell processes in the current session.

The second command gets the PowerShell process hosting the current session.

(Video) PowerShell for Beginners | Get-Process

Example 10: Get all processes that have a title in the main window and display them in a table

Get-Processo | Where-Object {$_.mainWindowTitle} | Format-Tabellen-ID, Name, mainWindowtitle -AutoSize

This command gets all processes that have a title in the main window and displays them in a table with process id and process name.

ÖMain window titleThe property is just one of the many useful properties of theProceedingscontradictget processReturns. To see all properties, pipe the results of aget processcommand for theGet MembercmdletGet-Processo | Get Member.

Parameter

-FileVersionInfo

Specifies that this cmdlet retrieves the file version information for the program running in the process.

On Windows Vista and later versions of Windows, you must open PowerShell with theExecute as administratorOption to use this parameter in processes you don't own.

To get file version information for a process on a remote computer, use thecall commandcmdlet.

Using this parameter is equivalent to gettingMainModule.FileVersionInfoProperty of each process object. If you use this parameter,get processreturns oneFileVersionInfoObjectSystem.Diagnostics.FileVersionInfo, not a process object. Therefore, you cannot pipe the command output to a cmdlet that expects a process object, such asstop process.

Typ:SwitchParameter
Last name:FV, FVI
Position:called
Default value:none
Accept pipeline input:INCORRECT
Accept wildcards:INCORRECT

-I walked

Identifies one or more processes by process ID (PID). To specify multiple IDs, use commas to separate the IDs. To find the PID of a process, typeget process.

Typ:Int32[]
Last name:PID
Position:called
Default value:none
Accept pipeline input:TRUE
Accept wildcards:INCORRECT

-Include username

Indicates that the UserName value of theProceedingsThe object is returned with the results of the command.

Typ:SwitchParameter
Position:called
Default value:none
Accept pipeline input:INCORRECT
Accept wildcards:INCORRECT

-input object

Specifies one or more process objects. Enter a variable that contains the objects or enter a command expression that gets the objects.

Typ:Proceedings[]
Position:called
Default value:none
Accept pipeline input:TRUE
Accept wildcards:INCORRECT
(Video) Basic PowerShell Pt10 Get-Process Tutorial

-Module

Indicates that this cmdlet retrieves modules loaded by processes.

On Windows Vista and later versions of Windows, you must open PowerShell with theExecute as administratorOption to use this parameter in processes you don't own.

To retrieve modules loaded by a process on a remote computer, use thecall commandcmdlet.

This parameter is equivalent to gettingModuleProperty of each process object. If you use this parameter, this cmdlet returns aProcessModuleObjectSystem.Diagnostics.ProcessModule, not a process object. Therefore, you cannot pipe the command output to a cmdlet that expects a process object, such asstop process.

If you use bothModuleeFileVersionInfoParameters in the same command, this cmdletre gives aFileVersionInfoObject with information about the file version of all modules.

Typ:SwitchParameter
Position:called
Default value:none
Accept pipeline input:INCORRECT
Accept wildcards:INCORRECT

-Name

Specifies one or more processes by process name. You can enter multiple process names (separated by commas) and use wildcard characters. The parameter name (Name) it is optional.

Typ:Corda[]
Last name:process name
Position:0
Default value:none
Accept pipeline input:TRUE
Accept wildcards:TRUE

starter

Proceedings

You can pipe a process object to this cmdlet.

departures

Proceedings

(Video) Process Management in PowerShell | PowerShell Tutorial

By default, this cmdlet returns aSystem.Diagnostics.ProcessObject.

FileVersionInfo

If you use theFileVersionInfoparameter, this cmdlet returns aFileVersionInfoObject.

ProcessModule

If you use theModuleparameters without whichFileVersionInfoparameter, this cmdlet returns aProcessModuleObject.

Nuts

PowerShell includes the following aliases forget process:

  • All platforms:

    • GPS
  • Window:

    • PS
  • You can also reference this cmdlet through its built-in aliases,PSeGPS. For more information, seeabout_aliases.

  • On computers running a 64-bit version of Windows, the 64-bit version of PowerShell only gets 64-bit process modules and the 32-bit version of PowerShell only gets 32-bit process modules.

  • You can use Windows Management Instrumentation (WMI) properties and methodsWin32_ProcessObject in PowerShell. For information seeGet-WmiObjectNamee or SDK do WMI.

  • The default view of a process is a table that contains the following columns. For a description of all properties of process objects, seeprocess properties.

    (Video) PowerShell Tutorial | Get-Process Part 2

    • Claw: The number of handles the process has opened.
    • NPM(K): The amount of non-paged memory the process is using, in kilobytes.
    • clock (K): The amount of pageable memory the process is using, in kilobytes.
    • WS(K): The working set size of the process in kilobytes. The working set consists of the memory pages last referenced by the process.
    • VM(M): The amount of virtual memory the process is using, in megabytes. Virtual memory includes storage in swap files on disk.
    • CPU(s): The amount of processor time the process used across all processors, in seconds.
    • I WALKED: The process ID (PID) of the process.
    • process name: The name of the process. For explanations of process-related concepts, see the Glossary in Help and Support Center and Task Manager Help.
  • You can also use the alternative built-in views of processes available withformat table, ifstart timeepriority, and you can design your own views.

  • debug process
  • get process
  • start process
  • stop process
  • waiting process

Videos

1. PowerShell For Beginners Full Course | PowerShell Beginner tutorial Full Course
(Nerd's lesson)
2. PowerShell For DevOps - List Running Processes on the Windows
(EasyTechStudios)
3. Get-Process \ PowerShell cmdlet review, one every day (POSHAD)
(spjeff)
4. Microsoft PowerShell for Beginners - Video 1 Learn PowerShell
(Shane Young)
5. PowerShell | Get-Service | Get-Process | Output on a notepad.
(PowerShell Experiments)
6. 15 Useful PowerShell Commands for Beginners | Learn Microsoft PowerShell
(WindowsChimp)
Top Articles
Latest Posts
Article information

Author: Kerri Lueilwitz

Last Updated: 01/28/2023

Views: 6220

Rating: 4.7 / 5 (47 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Kerri Lueilwitz

Birthday: 1992-10-31

Address: Suite 878 3699 Chantelle Roads, Colebury, NC 68599

Phone: +6111989609516

Job: Chief Farming Manager

Hobby: Mycology, Stone skipping, Dowsing, Whittling, Taxidermy, Sand art, Roller skating

Introduction: My name is Kerri Lueilwitz, I am a courageous, gentle, quaint, thankful, outstanding, brave, vast person who loves writing and wants to share my knowledge and understanding with you.