Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion data.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"NOTICE.txt",
"osinfo",
"osinfo.dsc.resource.json",
"process",
"process.dsc.manifests.json",
"powershell.dsc.extension.json",
"powershell.discover.ps1",
"powershell.dsc.resource.json",
Expand Down Expand Up @@ -53,6 +55,8 @@
"NOTICE.txt",
"osinfo",
"osinfo.dsc.resource.json",
"process",
"process.dsc.manifests.json",
"powershell.dsc.extension.json",
"powershell.discover.ps1",
"powershell.dsc.resource.json",
Expand Down Expand Up @@ -92,6 +96,8 @@
"optionalfeature.dsc.resource.json",
"osinfo.exe",
"osinfo.dsc.resource.json",
"process.exe",
"process.dsc.manifests.json",
"powershell.dsc.extension.json",
"powershell.discover.ps1",
"powershell.dsc.resource.json",
Expand Down Expand Up @@ -383,7 +389,7 @@
],
"CopyFiles": {
"All": [
"process.dsc.resource.json"
"process.dsc.manifests.json"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/resources/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Microsoft.Windows/Registry Resource 0.1.0 gs-w-d--
Microsoft.Windows/WMI Adapter 0.1.0 g------- Resource adapter to WMI resources.
Microsoft.Windows/WindowsPowerShell Adapter 0.1.0 gs--t--- Resource adapter to classic DSC Powershell resources in Windows PowerShell.
Microsoft/OSInfo Resource 0.1.0 g-----e- Returns information about the operating system.
Microsoft/Process Resource 0.1.0 gs--t-e- Returns information about running processes.
Microsoft.System/Process Resource 0.1.0 g-----e- Returns information about running processes.
```

You can filter the results by a resource's type name, description, and tags. For more information,
Expand Down
2 changes: 1 addition & 1 deletion docs/get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Microsoft.Windows/Registry Resource 0.1.0 gs-w-d--
Microsoft.Windows/WMI Adapter 0.1.0 g------- Resource adapter to WMI resources.
Microsoft.Windows/WindowsPowerShell Adapter 0.1.0 gs--t--- Resource adapter to classic DSC Powershell resources in Windows PowerShell.
Microsoft/OSInfo Resource 0.1.0 g-----e- Returns information about the operating system.
Microsoft/Process Resource 0.1.0 gs--t-e- Returns information about running processes.
Microsoft.System/Process Resource 0.1.0 g-----e- Returns information about running processes.
```

Together, the columns describe each resource:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli/config/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ resources:
type: Microsoft/OSInfo
properties: {}
- name: Processes
type: Microsoft/Process
type: Microsoft.System/Process
properties: {}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
description: Terminate an explicitly selected process using a DSC configuration.
ms.date: 11/09/2026
ms.topic: reference
title: Terminate a selected process
---

# Terminate a selected process

Inspect processes first with `Microsoft.System/Process`. Replace `1234` below with the PID
of a disposable process that you intend to terminate.

Save the following configuration as [terminate.config.dsc.yaml](./terminate.config.dsc.yaml):

```yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Terminate selected process
type: Microsoft.System.Action/TerminateProcess
properties:
pid: 1234
```

Run it on any supported platform:

```powershell
dsc config set -f terminate.config.dsc.yaml
```

The action's `afterState.terminated` array identifies the processes whose termination requests
succeeded.

To terminate all processes with one exact name, replace `pid` with `name`:

```yaml
properties:
name: my-disposable-process
```

Use the name returned by `Microsoft.System/Process`. On Windows this typically includes `.exe`.
Don't specify both selectors. Wildcards aren't supported by the termination action.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Terminate selected process
type: Microsoft.System.Action/TerminateProcess
properties:
pid: 1234
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
description: Microsoft.System.Action/TerminateProcess DSC action reference documentation
ms.date: 11/09/2026
ms.topic: reference
title: Microsoft.System.Action/TerminateProcess
---

# Microsoft.System.Action/TerminateProcess

## Synopsis

Terminates a process by PID or every process with an exact name on Windows, Linux, and macOS.

## Metadata

```yaml
Version : 0.1.0
Kind : action
Tags : [Windows, Linux, macOS, Process]
Author : Microsoft
```

## Instance definition syntax

```yaml
resources:
- name: Terminate selected process
type: Microsoft.System.Action/TerminateProcess
properties:
# Specify exactly one of pid or name.
pid: 1234
```

## Description

This action runs only during configuration `set`. It forcefully terminates the selected process
using the native process library (`TerminateProcess` on Windows and `SIGKILL` on Unix).
It doesn't create processes or implement desired-state management.

Provide exactly one selector. `pid` targets one process; `name` targets every matching process
in a snapshot. Names match exactly, case-insensitively on Windows and case-sensitively on Linux
and macOS. Wildcards aren't accepted. Use the names returned by [Microsoft.System/Process][01],
including any platform-specific extension or truncation.

> [!WARNING]
> Termination can cause data loss. Specifying a name terminates **all** processes with that name
> that the caller has permission to terminate. Prefer a PID when targeting one instance.

Process 0 and the executable running the action can't be targeted. No matching processes, or a
failed termination request, produces an error. The action attempts every matching process even
if a termination fails. A partial failure can't be rolled back; the error lists failed PIDs.
Success means termination requests succeeded; process cleanup can finish asynchronously.
Processes started after enumeration aren't included.

The action returns a `terminated` array containing each targeted process's `pid`, `name`,
and `cmdline` snapshot. It doesn't support what-if.

> [!NOTE]
> This action is installed with DSC itself on all platforms. Update DSC to update this action.

## Requirements

The caller must have permission to terminate each target. Elevated privileges may be needed for
processes owned by other users. Protected processes can still reject termination.

## Capabilities

- `set` - Invokes termination through `dsc config set`.

## Examples

1. [Terminate a selected process][02]

## Properties

Exactly one of [pid](#pid) or [name](#name) is required.

### pid

<details><summary>Expand for <code>pid</code> property metadata</summary>

```yaml
Type : integer
IsRequired : false
IsKey : false
IsReadOnly : false
IsWriteOnly: false
Minimum : 1
Maximum : 4294967295
```

</details>

The process identifier to terminate. Can't be combined with `name`.

### name

<details><summary>Expand for <code>name</code> property metadata</summary>

```yaml
Type : string
IsRequired : false
IsKey : false
IsReadOnly : false
IsWriteOnly: false
```

</details>

An exact, nonempty process name. Can't contain `*` or be combined with `pid`.
Every process with this name is targeted.

## Instance validating schema

```json
{
"type": "object",
"additionalProperties": false,
"oneOf": [
{ "required": ["pid"] },
{ "required": ["name"] }
],
"properties": {
"pid": { "type": "integer", "minimum": 1, "maximum": 4294967295 },
"name": { "type": "string", "minLength": 1, "pattern": "^[^*]+$" }
}
}
```

## Exit codes

- [0](#exit-code-0) - Success.
- [1](#exit-code-1) - Invalid arguments.
- [2](#exit-code-2) - Invalid input.
- [3](#exit-code-3) - Process enumeration or termination failed.

### Exit code 0

All targeted termination requests succeeded.

### Exit code 1

The executable arguments are invalid. An error message explains the expected syntax.

### Exit code 2

Input validation failed. An error message describes the invalid selector.

### Exit code 3

Enumeration failed, no process matched, the target was unsafe, or termination failed.
An error message describes the problem. Some processes might already have terminated.

## See also

- [Microsoft.System/Process][01]

<!-- Link definitions -->
[01]: ../../Process/index.md
[02]: ./examples/terminate-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
description: Query one process or export matching processes on Windows, Linux, and macOS.
ms.date: 11/09/2026
ms.topic: reference
title: Query and export running processes
---

# Query and export running processes

## Get the current PowerShell process

Run these commands in PowerShell on any supported platform:

```powershell
@{ pid = $PID } | ConvertTo-Json -Compress |
dsc resource get -r Microsoft.System/Process -f -
```

The `actualState` contains the PID, name, and individual command-line arguments.
For example:

```yaml
actualState:
pid: 1234
name: pwsh
cmdline:
- pwsh
```

## Export processes using a name wildcard

```powershell
'{"name":"pwsh*"}' | dsc resource export -r Microsoft.System/Process -f -
```

The output is a configuration containing one instance per matching process. An unmatched name
produces an empty `resources` array without an error.

Export without filters:

```powershell
dsc resource export -r Microsoft.System/Process
```

Combine filters to select only the current PowerShell process:

```powershell
@{ pid = $PID; name = 'pwsh*' } | ConvertTo-Json -Compress |
dsc resource export -r Microsoft.System/Process -f -
```
Loading
Loading