Win32_Process

Win32 Process
root/cimv2dynamickey : Handle

The Win32_Process WMI class represents a process on an operating system.

On this page

Main example

List instances

# All instances of Win32_Process, with the main properties
Get-CimInstance -ClassName Win32_Process |
    Select-Object -Property @(
        'ProcessId'
        'Name'
        'CommandLine'
        'ParentProcessId'
        @{ Name = 'WorkingSetSizeMB'; Expression = { [math]::Round($_.WorkingSetSize / 1MB, 2) } }
        'CreationDate'
    )

Examples

Filter with WQL

# WQL filter evaluated by the provider: processes with this name
Get-CimInstance -ClassName Win32_Process -Filter "Name = 'powershell.exe'" |
    Select-Object -Property @(
        'ProcessId'
        'Name'
        'CommandLine'
        'ParentProcessId'
        @{ Name = 'WorkingSetSizeMB'; Expression = { [math]::Round($_.WorkingSetSize / 1MB, 2) } }
        'CreationDate'
    )

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Decode numeric values

# Lookup table for ExecutionState (values documented by Microsoft)
$executionStateName = @{
    0 = 'Unknown'
    1 = 'Other'
    2 = 'Ready'
    3 = 'Running'
    4 = 'Blocked'
    5 = 'Suspended Blocked'
    6 = 'Suspended Ready'
    7 = 'Terminated'
    8 = 'Stopped'
    9 = 'Growing'
}

Get-CimInstance -ClassName Win32_Process |
    Select-Object -Property @(
        'ProcessId'
        'Name'
        'CommandLine'
        'ParentProcessId'
        @{ Name = 'WorkingSetSizeMB'; Expression = { [math]::Round($_.WorkingSetSize / 1MB, 2) } }
        'CreationDate'
        @{ Name = 'ExecutionState'; Expression = { $executionStateName[[int]$_.ExecutionState] } }
    )

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    Get-CimInstance -CimSession $cimSession -ClassName Win32_Process |
        Select-Object -Property @(
            'ProcessId'
            'Name'
            'CommandLine'
            'ParentProcessId'
            @{ Name = 'WorkingSetSizeMB'; Expression = { [math]::Round($_.WorkingSetSize / 1MB, 2) } }
            'CreationDate'
        )
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_Process
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

# Methods of the class
$cimClass.CimClassMethods |
    Select-Object -Property Name, ReturnType

Properties

45 of 45 properties
NameTypeAccessDescription
Captionstringread

Short description of an object—a one-line string.

Code
# Value of Caption for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, Caption |
    Select-Object -Property CSName, Handle, Caption
CommandLinestringread

Command line used to start a specific process, if applicable.

Code
# Value of CommandLine for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, CommandLine |
    Select-Object -Property CSName, Handle, CommandLine
CreationClassName keystringread

Name of the class or subclass used in the creation of an instance. When used with other key properties of the class, this property allows all instances of the class and its subclasses to be uniquely identified.

Code
# Value of CreationClassName for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, CreationClassName |
    Select-Object -Property CSName, Handle, CreationClassName
CreationDatedatetimeread

Date the process begins executing.

Code
# Value of CreationDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, CreationDate |
    Select-Object -Property CSName, Handle, CreationDate
CSCreationClassName keystringread

Creation class name of the scoping computer system.

Code
# Value of CSCreationClassName for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, CSCreationClassName |
    Select-Object -Property CSName, Handle, CSCreationClassName
CSName keystringread

Name of the scoping computer system.

Code
# Value of CSName for each instance
Get-CimInstance -ClassName Win32_Process -Property Handle, CSName |
    Select-Object -Property Handle, CSName
Descriptionstringread

Description of an object.

Code
# Value of Description for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, Description |
    Select-Object -Property CSName, Handle, Description
ExecutablePathstringread

Path to the executable file of the process.

Example: "C:\Windows\System\Explorer.Exe"

Code
# Value of ExecutablePath for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ExecutablePath |
    Select-Object -Property CSName, Handle, ExecutablePath
ExecutionStateuint16read

Current operating condition of the process.

Values (10)
ValueLabelDescription
0Unknown
1Other
2Ready
3Running
4Blocked
5Suspended Blocked
6Suspended Ready
7Terminated
8Stopped
9Growing
Code
# Value of ExecutionState for each instance
# Lookup table for ExecutionState (values documented by Microsoft)
$executionStateName = @{
    0 = 'Unknown'
    1 = 'Other'
    2 = 'Ready'
    3 = 'Running'
    4 = 'Blocked'
    5 = 'Suspended Blocked'
    6 = 'Suspended Ready'
    7 = 'Terminated'
    8 = 'Stopped'
    9 = 'Growing'
}
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ExecutionState |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'ExecutionState'; Expression = { $executionStateName[[int]$_.ExecutionState] } }
    )
Handle keystringread

Process identifier.

Code
# Value of Handle for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle |
    Select-Object -Property CSName, Handle
HandleCountuint32read

Total number of open handles owned by the process. HandleCount is the sum of the handles currently open by each thread in this process. A handle is used to examine or modify the system resources. Each handle has an entry in a table that is maintained internally. Entries contain the addresses of the resources and data to identify the resource type.

Code
# Value of HandleCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, HandleCount |
    Select-Object -Property CSName, Handle, HandleCount
InstallDatedatetimeread

Date an object is installed. The object may be installed without a value being written to this property.

Code
# Value of InstallDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, InstallDate |
    Select-Object -Property CSName, Handle, InstallDate
KernelModeTimeuint64read

Time in kernel mode, in milliseconds. If this information is not available, use a value of 0 (zero).

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: 100 nanoseconds

Code
# Value of KernelModeTime for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, KernelModeTime |
    Select-Object -Property CSName, Handle, KernelModeTime
MaximumWorkingSetSizeuint32read

Maximum working set size of the process. The working set of a process is the set of memory pages visible to the process in physical RAM. These pages are resident, and available for an application to use without triggering a page fault.

Example: 1413120

Unit: kilobytes

Code
# Value of MaximumWorkingSetSize for each instance
# MaximumWorkingSetSize is expressed in kilobytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, MaximumWorkingSetSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'MaximumWorkingSetSizeGB'; Expression = { [math]::Round($_.MaximumWorkingSetSize / 1MB, 2) } }
    )
MinimumWorkingSetSizeuint32read

Minimum working set size of the process. The working set of a process is the set of memory pages visible to the process in physical RAM. These pages are resident and available for an application to use without triggering a page fault.

Example: 20480

Unit: kilobytes

Code
# Value of MinimumWorkingSetSize for each instance
# MinimumWorkingSetSize is expressed in kilobytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, MinimumWorkingSetSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'MinimumWorkingSetSizeGB'; Expression = { [math]::Round($_.MinimumWorkingSetSize / 1MB, 2) } }
    )
Namestringread

Name of the executable file responsible for the process, equivalent to the Image Name property in Task Manager.

When inherited by a subclass, the property can be overridden to be a key property. The name is hard-coded into the application itself and is not affected by changing the file name. For example, even if you rename Calc.exe, the name Calc.exe will still appear in Task Manager and in any WMI scripts that retrieve the process name.

Code
# Value of Name for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, Name |
    Select-Object -Property CSName, Handle, Name
OSCreationClassName keystringread

Creation class name of the scoping operating system.

Code
# Value of OSCreationClassName for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, OSCreationClassName |
    Select-Object -Property CSName, Handle, OSCreationClassName
OSName keystringread

Name of the scoping operating system.

Code
# Value of OSName for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, OSName |
    Select-Object -Property CSName, Handle, OSName
OtherOperationCountuint64read

Number of I/O operations performed that are not read or write operations.

For more information about using uint64 values in scripts, see Scripting in WMI.

Code
# Value of OtherOperationCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, OtherOperationCount |
    Select-Object -Property CSName, Handle, OtherOperationCount
OtherTransferCountuint64read

Amount of data transferred during operations that are not read or write operations.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of OtherTransferCount for each instance
# OtherTransferCount is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, OtherTransferCount |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'OtherTransferCountGB'; Expression = { [math]::Round($_.OtherTransferCount / 1GB, 2) } }
    )
PageFaultsuint32read

Number of page faults that a process generates.

Example: 10

Code
# Value of PageFaults for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PageFaults |
    Select-Object -Property CSName, Handle, PageFaults
PageFileUsageuint32read

Amount of page file space that a process is using currently. This value is consistent with the VMSize value in TaskMgr.exe.

Example: 102435

Unit: kilobytes

Code
# Value of PageFileUsage for each instance
# PageFileUsage is expressed in kilobytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PageFileUsage |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'PageFileUsageGB'; Expression = { [math]::Round($_.PageFileUsage / 1MB, 2) } }
    )
ParentProcessIduint32read

Unique identifier of the process that creates a process. Process identifier numbers are reused, so they only identify a process for the lifetime of that process. It is possible that the process identified by ParentProcessId is terminated, so ParentProcessId may not refer to a running process. It is also possible that ParentProcessId incorrectly refers to a process that reuses a process identifier. You can use the CreationDate property to determine whether the specified parent was created after the process represented by this Win32_Process instance was created.

Code
# Value of ParentProcessId for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ParentProcessId |
    Select-Object -Property CSName, Handle, ParentProcessId
PeakPageFileUsageuint32read

Maximum amount of page file space used during the life of a process.

Example: 102367

Unit: kilobytes

Code
# Value of PeakPageFileUsage for each instance
# PeakPageFileUsage is expressed in kilobytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PeakPageFileUsage |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'PeakPageFileUsageGB'; Expression = { [math]::Round($_.PeakPageFileUsage / 1MB, 2) } }
    )
PeakVirtualSizeuint64read

Maximum virtual address space a process uses at any one time. Using virtual address space does not necessarily imply corresponding use of either disk or main memory pages. However, virtual space is finite, and by using too much the process might not be able to load libraries.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of PeakVirtualSize for each instance
# PeakVirtualSize is expressed in bytes: converted to MB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PeakVirtualSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'PeakVirtualSizeMB'; Expression = { [math]::Round($_.PeakVirtualSize / 1MB, 2) } }
    )
PeakWorkingSetSizeuint32read

Peak working set size of a process.

Example: 1413120

Unit: kilobytes

Code
# Value of PeakWorkingSetSize for each instance
# PeakWorkingSetSize is expressed in kilobytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PeakWorkingSetSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'PeakWorkingSetSizeGB'; Expression = { [math]::Round($_.PeakWorkingSetSize / 1MB, 2) } }
    )
Priorityuint32read

Scheduling priority of a process within an operating system. The higher the value, the higher priority a process receives. Priority values can range from 0 (zero), which is the lowest priority to 31, which is highest priority.

Example: 7

Code
# Value of Priority for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, Priority |
    Select-Object -Property CSName, Handle, Priority
PrivatePageCountuint64read

Current number of pages allocated that are only accessible to the process represented by this Win32_Process instance.

For more information about using uint64 values in scripts, see Scripting in WMI.

Code
# Value of PrivatePageCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, PrivatePageCount |
    Select-Object -Property CSName, Handle, PrivatePageCount
ProcessIduint32read

Numeric identifier used to distinguish one process from another. ProcessIDs are valid from process creation time to process termination. Upon termination, that same numeric identifier can be applied to a new process.

This means that you cannot use ProcessID alone to monitor a particular process. For example, an application could have a ProcessID of 7, and then fail. When a new process is started, the new process could be assigned ProcessID 7. A script that checked only for a specified ProcessID could thus be "fooled" into thinking that the original application was still running.

Code
# Value of ProcessId for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ProcessId |
    Select-Object -Property CSName, Handle, ProcessId
QuotaNonPagedPoolUsageuint32read

Quota amount of nonpaged pool usage for a process.

Example: 15

Code
# Value of QuotaNonPagedPoolUsage for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, QuotaNonPagedPoolUsage |
    Select-Object -Property CSName, Handle, QuotaNonPagedPoolUsage
QuotaPagedPoolUsageuint32read

Quota amount of paged pool usage for a process.

Example: 22

Code
# Value of QuotaPagedPoolUsage for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, QuotaPagedPoolUsage |
    Select-Object -Property CSName, Handle, QuotaPagedPoolUsage
QuotaPeakNonPagedPoolUsageuint32read

Peak quota amount of nonpaged pool usage for a process.

Example: 31

Code
# Value of QuotaPeakNonPagedPoolUsage for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, QuotaPeakNonPagedPoolUsage |
    Select-Object -Property CSName, Handle, QuotaPeakNonPagedPoolUsage
QuotaPeakPagedPoolUsageuint32read

Peak quota amount of paged pool usage for a process.

Example: 31

Code
# Value of QuotaPeakPagedPoolUsage for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, QuotaPeakPagedPoolUsage |
    Select-Object -Property CSName, Handle, QuotaPeakPagedPoolUsage
ReadOperationCountuint64read

Number of read operations performed.

For more information about using uint64 values in scripts, see Scripting in WMI.

Code
# Value of ReadOperationCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ReadOperationCount |
    Select-Object -Property CSName, Handle, ReadOperationCount
ReadTransferCountuint64read

Amount of data read.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of ReadTransferCount for each instance
# ReadTransferCount is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ReadTransferCount |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'ReadTransferCountGB'; Expression = { [math]::Round($_.ReadTransferCount / 1GB, 2) } }
    )
SessionIduint32read

Unique identifier that an operating system generates when a session is created. A session spans a period of time from logon until logoff from a specific system.

Code
# Value of SessionId for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, SessionId |
    Select-Object -Property CSName, Handle, SessionId
Statusstringread

This property is not implemented and does not get populated for any instance of this class. It is always NULL.

Values include the following:

Values (12)
ValueLabelDescription
OKOK
ErrorError
DegradedDegraded
UnknownUnknown
Pred FailPred Fail
StartingStarting
StoppingStopping
ServiceService
StressedStressed
NonRecoverNonRecover
No ContactNo Contact
Lost CommLost Comm
Code
# Value of Status for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, Status |
    Select-Object -Property CSName, Handle, Status
TerminationDatedatetimeread

Process was stopped or terminated. To get the termination time, a handle to the process must be held open. Otherwise, this property returns NULL.

Code
# Value of TerminationDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, TerminationDate |
    Select-Object -Property CSName, Handle, TerminationDate
ThreadCountuint32read

Number of active threads in a process. An instruction is the basic unit of execution in a processor, and a thread is the object that executes an instruction. Each running process has at least one thread.

Code
# Value of ThreadCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, ThreadCount |
    Select-Object -Property CSName, Handle, ThreadCount
UserModeTimeuint64read

Time in user mode, in 100 nanosecond units. If this information is not available, use a value of 0 (zero).

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: 100 nanoseconds

Code
# Value of UserModeTime for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, UserModeTime |
    Select-Object -Property CSName, Handle, UserModeTime
VirtualSizeuint64read

Current size of the virtual address space that a process is using, not the physical or virtual memory actually used by the process. Using virtual address space does not necessarily imply corresponding use of either disk or main memory pages. Virtual space is finite, and by using too much, the process might not be able to load libraries. This value is consistent with what you see in Perfmon.exe.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of VirtualSize for each instance
# VirtualSize is expressed in bytes: converted to MB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, VirtualSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'VirtualSizeMB'; Expression = { [math]::Round($_.VirtualSize / 1MB, 2) } }
    )
WindowsVersionstringread

Version of Windows in which the process is running.

Example: 4.0

Code
# Value of WindowsVersion for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, WindowsVersion |
    Select-Object -Property CSName, Handle, WindowsVersion
WorkingSetSizeuint64read

Amount of memory in bytes that a process needs to execute efficiently—for an operating system that uses page-based memory management. If the system does not have enough memory (less than the working set size), thrashing occurs. If the size of the working set is not known, use NULL or 0 (zero). If working set data is provided, you can monitor the information to understand the changing memory requirements of a process.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of WorkingSetSize for each instance
# WorkingSetSize is expressed in bytes: converted to MB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, WorkingSetSize |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'WorkingSetSizeMB'; Expression = { [math]::Round($_.WorkingSetSize / 1MB, 2) } }
    )
WriteOperationCountuint64read

Number of write operations performed.

For more information about using uint64 values in scripts, see Scripting in WMI.

Code
# Value of WriteOperationCount for each instance
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, WriteOperationCount |
    Select-Object -Property CSName, Handle, WriteOperationCount
WriteTransferCountuint64read

Amount of data written.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of WriteTransferCount for each instance
# WriteTransferCount is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_Process -Property CSName, Handle, WriteTransferCount |
    Select-Object -Property @(
        'CSName'
        'Handle'
        @{ Name = 'WriteTransferCountGB'; Expression = { [math]::Round($_.WriteTransferCount / 1GB, 2) } }
    )

Methods

AttachDebugger #

Launches the currently registered debugger for a process.

uint32 AttachDebugger();

Return values

ValueLabelDescription
0Successful completion
2Access deniedThe user does not have access to the requested information.
3Insufficient privilegeThe user does not have sufficient privilege.
8Unknown failure
9Path not foundThe path specified does not exist.
21Invalid parameterThe specified parameter is not valid.
22..4294967295Other

Call the AttachDebugger method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'AttachDebugger'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Create static#

Creates a new process.

uint32 Create(
    [in] string CommandLine,
    [in] string CurrentDirectory,
    [in] Win32_ProcessStartup ProcessStartupInformation,
    [out] uint32 ProcessId
);

Parameters

ParameterTypeDirectionDescription
CommandLinestringin

Command line to execute. The system adds a null character to the command line, trimming the string if necessary, to indicate which file was actually used.

CurrentDirectorystringin

Current drive and directory for the child process. The string requires that the current directory resolves to a known path. A user can specify an absolute path or a path relative to the current working directory. If this parameter is NULL, the new process will have the same path as the calling process. This option is provided primarily for shells that must start an application and specify the application's initial drive and working directory.

ProcessStartupInformationWin32_ProcessStartupin

The startup configuration of a Windows process. For more information, see Win32_ProcessStartup.

ProcessIduint32out

Global process identifier that can be used to identify a process. The value is valid from the time the process is created until the time the process is terminated.

Return values

ValueLabelDescription
0Successful completion
2Access denied
3Insufficient privilege
8Unknown failure
9Path not found
21Invalid parameter
22..4294967295Other

Call the Create method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
$methodParameters = @{
    ClassName  = 'Win32_Process'
    MethodName = 'Create'
    Arguments  = @{
        CommandLine               = 'notepad.exe'
        CurrentDirectory          = 'Example'
        ProcessStartupInformation = $null
    }
    WhatIf     = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.ProcessId
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

GetAvailableVirtualSize #

Retrieves the current size, in bytes, of the free virtual address space available to the process. Windows Server 2012, Windows 8, Windows 7, Windows Server 2008 and Windows Vista: This method is not supported before Windows 8.1 and Windows Server 2012 R2.

uint32 GetAvailableVirtualSize([out] uint64 AvailableVirtualSize);

Parameters

ParameterTypeDirectionDescription
AvailableVirtualSizeuint64out

The *AvailableVirtualSize* parameter returns the free virtual address space available to this process.

Return values

ValueLabelDescription
0Successful completionThe operation completed successfully.
2Access deniedThe user does not have access to the requested information
3Insufficient privilegeThe user does not have sufficient privilege.
8Unknown failure
9Path not foundThe path specified does not exist.
21Invalid parameterThe specified parameter is invalid.
22..4294967295OtherFor values other than those listed, refer to the System Error Codes documentation.

Call the GetAvailableVirtualSize method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'GetAvailableVirtualSize'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.AvailableVirtualSize
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

GetOwner #

Retrieves the user name and domain name under which the process is running.

uint32 GetOwner([out] string User, [out] string Domain);

Parameters

ParameterTypeDirectionDescription
Userstringout

Returns the user name of the owner of this process.

Domainstringout

Returns the domain name under which this process is running.

Return values

ValueLabelDescription
0Successful completion
2Access denied
3Insufficient privilege
8Unknown failure
9Path not found
21Invalid parameter
22..4294967295Other

Call the GetOwner method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'GetOwner'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.User
    $result.Domain
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

GetOwnerSid #

Retrieves the security identifier (SID) for the owner of a process.

uint32 GetOwnerSid([out] string Sid);

Parameters

ParameterTypeDirectionDescription
Sidstringout

Returns the security identifier descriptor for this process.

Return values

ValueLabelDescription
0Successful completion
2Access denied
3Insufficient privilege
8Unknown failure
9Path not found
21Invalid parameter
22..4294967295Other

Call the GetOwnerSid method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'GetOwnerSid'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.Sid
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

SetPriority #

Changes the execution priority of a process.

uint32 SetPriority([in] sint32 Priority);

Parameters

ParameterTypeDirectionDescription
Prioritysint32in

New priority class for the process. Note that these values are different than those explicitly stated in the Priority property of Win32_Process.

Return values

ValueLabelDescription
0Successful completion
2Access denied
3Insufficient privilege
8Unknown failure
9Path not found
21Invalid parameter
22..4294967295Other

Call the SetPriority method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'SetPriority'
    Arguments   = @{ Priority = 32 }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Terminate #

Terminates a process and all of its threads.

uint32 Terminate([in] uint32 Reason);

Parameters

ParameterTypeDirectionDescription
Reasonuint32in

Exit code for the process and for all of the threads terminated as a result of this call.

Return values

ValueLabelDescription
0Successful completion
2Access denied
3Insufficient privilege
8Unknown failure
9Path not found
21Invalid parameter
22..4294967295Other

Call the Terminate method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Terminate'
    Arguments   = @{ Reason = 1 }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Successful completion'
        2 = 'Access denied'
        3 = 'Insufficient privilege'
        8 = 'Unknown failure'
        9 = 'Path not found'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Remarks

The Win32_Process class is derived from CIM_Process. The calling process that uses this class must have the SE_RESTORE_NAME privilege on the computer in which the registry resides. For more information, see Executing Privileged Operations.

### Overview

Processes underlie almost everything that happens on a computer. In fact, the root cause of most computer problems can be traced to processes; for example, too many processes might be running on a computer (and contending for a finite set of resources), or a single process might be using more than its share of resources. These factors make it important to keep a close watch on the processes running on a computer. Process monitoring, the main activity in process management, allows you to determine what a computer actually does, what applications the computer runs, and how those applications are affected by changes in the computing environment.

### Monitoring a Process

Monitoring processes on a regular basis helps you ensure that a computer runs at peak efficiency and that it carries out its appointed tasks as expected. For example, by monitoring processes you can be notified immediately of any application that has stopped responding, and then take steps to end that process. In addition, process monitoring enables you to identify problems before they occur. For example, by repeatedly checking the amount of memory used by a process, you can identify a memory leak. You can then stop the process before the errant application uses all of the available memory and brings the computer to a halt.

Process monitoring also helps minimize the disruptions caused by planned outages for upgrades and maintenance. For example, by checking the status of a database application running on client computers, you can determine the impact of taking the database offline in order to upgrade the software.

Monitoring process availability. Measures the percentage of time that a process is available. Availability is typically monitored by use of a simple probe, which reports whether the process is still running. By keeping track of the results of each probe, you can calculate the availability of the process. For example, a process that is probed 100 times and responds on 95 of those occasions has an availability of 95 percent. This type of monitoring is typically reserved for databases, mail programs, and other applications that are expected to run at all times. It is not appropriate for word processing programs, spreadsheets, or other applications that are routinely started and stopped several times a day.

You can create an instance of the Win32_ProcessStartup class to configure the process.

You can monitor process performance with the Win32_PerfFormattedData_PerfProc_Process class and a WMI refresher object, such as SWbemRefresher. For more information, see Monitoring Performance Data.

Inheritance

Superclass chain

  1. CIM_ManagedSystemElement
  2. CIM_LogicalElement
  3. CIM_Process
  4. Win32_Process

Known subclasses

No known subclass.

Requirements

Namespace
root/cimv2
Minimum client
Windows Vista
Minimum server
Windows Server 2008
Provider
CIMWin32
MOF file
CIMWin32.mof
DLL
CIMWin32.dll
Class qualifiers

Dynamic Provider("CIMWin32") SupportsCreate CreateBy("Create") SupportsDelete DeleteBy("DeleteInstance") UUID("{8502C4DC-5FBB-11D2-AAC1-006008C78BC7}") DisplayName("Processes") AMENDMENT

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.