Skip to content

Commit e1e6e96

Browse files
Merge pull request #12794 from MicrosoftDocs/main
Auto Publish – main to live - 2026-02-24 23:00 UTC
2 parents bb52269 + b109ee6 commit e1e6e96

8 files changed

Lines changed: 246 additions & 184 deletions

reference/docs-conceptual/developer/cmdlet/confirmation-messages.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ title: Confirmation Messages
66
# Confirmation Messages
77

88
Here are different confirmation messages that can be displayed depending on the variants of the
9-
[System.Management.Automation.Cmdlet.ShouldProcess](/dotnet/api/System.Management.Automation.Cmdlet.ShouldProcess)
10-
and
11-
[System.Management.Automation.Cmdlet.ShouldContinue](/dotnet/api/System.Management.Automation.Cmdlet.ShouldContinue)
12-
methods that are called.
9+
[System.Management.Automation.Cmdlet.ShouldProcess][04] and
10+
[System.Management.Automation.Cmdlet.ShouldContinue][03] methods that are called.
1311

1412
> [!IMPORTANT]
1513
> For sample code that shows how to request confirmations, see
16-
> [How to Request Confirmations](./how-to-request-confirmations.md).
14+
> [Requesting Confirmation from Cmdlets][01].
1715
1816
## Specifying the Resource
1917

2018
You can specify the resource that is about to be changed by calling the
21-
[System.Management.Automation.Cmdlet.ShouldProcess](/dotnet/api/System.Management.Automation.Cmdlet.ShouldProcess)
22-
method. In this case, you supply the resource by using the `target` parameter of the method, and the
23-
operation is added by Windows PowerShell. In the following message, the text "MyResource" is the
24-
resource acted on and the operation is the name of the command that makes the call.
19+
[System.Management.Automation.Cmdlet.ShouldProcess][04] method. In this case, you supply the
20+
resource by using the `target` parameter of the method, and the operation is added by Windows
21+
PowerShell. In the following message, the text "MyResource" is the resource acted on and the
22+
operation is the name of the command that makes the call.
2523

2624
```Output
2725
Confirm
@@ -31,9 +29,8 @@ Performing operation "Test-RequestConfirmationTemplate1" on Target "MyResource".
3129
```
3230

3331
If the user selects **Yes** or **Yes to All** to the confirmation request (as shown in the following
34-
example), a call to the
35-
[System.Management.Automation.Cmdlet.ShouldContinue](/dotnet/api/System.Management.Automation.Cmdlet.ShouldContinue)
36-
method is made, which causes a second confirmation message to be displayed.
32+
example), a call to the [System.Management.Automation.Cmdlet.ShouldContinue][03] method is made,
33+
which causes a second confirmation message to be displayed.
3734

3835
```Output
3936
Confirm
@@ -49,11 +46,10 @@ Continue with this operation?
4946
## Specifying the Operation and Resource
5047

5148
You can specify the resource that is about to be changed and the operation that the command is about
52-
to perform by calling the
53-
[System.Management.Automation.Cmdlet.ShouldProcess](/dotnet/api/System.Management.Automation.Cmdlet.ShouldProcess)
54-
method. In this case, you supply the resource by using the `target` parameter and the operation by
55-
using the `target` parameter. In the following message, the text "MyResource" is the resource acted
56-
on and "MyAction" is the operation to be performed.
49+
to perform by calling the [System.Management.Automation.Cmdlet.ShouldProcess][04] method. In this
50+
case, you supply the resource by using the `target` parameter and the operation by using the
51+
`target` parameter. In the following message, the text "MyResource" is the resource acted on and
52+
"MyAction" is the operation to be performed.
5753

5854
```Output
5955
Confirm
@@ -63,8 +59,8 @@ Performing operation "MyAction" on Target "MyResource".
6359
```
6460

6561
If the user selects **Yes** or **Yes to All** to the previous message, a call to the
66-
[System.Management.Automation.Cmdlet.ShouldContinue](/dotnet/api/System.Management.Automation.Cmdlet.ShouldContinue)
67-
method is made, which causes a second confirmation message to be displayed.
62+
[System.Management.Automation.Cmdlet.ShouldContinue][03] method is made, which causes a second
63+
confirmation message to be displayed.
6864

6965
```Output
7066
Confirm
@@ -79,4 +75,10 @@ Continue with this operation?
7975

8076
## See Also
8177

82-
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)
78+
[Writing a Windows PowerShell Cmdlet][02]
79+
80+
<!-- link references -->
81+
[01]: ./requesting-confirmation-from-cmdlets.md
82+
[02]: ./writing-a-windows-powershell-cmdlet.md
83+
[03]: xref:System.Management.Automation.Cmdlet.ShouldContinue%2A
84+
[04]: xref:System.Management.Automation.Cmdlet.ShouldProcess%2A

reference/docs-conceptual/developer/cmdlet/creating-a-cmdlet-that-modifies-the-system.md

Lines changed: 85 additions & 94 deletions
Large diffs are not rendered by default.

reference/docs-conceptual/developer/cmdlet/examples-of-cmdlet-code.md

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,54 @@ title: Examples of Cmdlet Code
88
This section contains examples of cmdlet code that you can use to start writing your own cmdlets.
99

1010
> [!IMPORTANT]
11-
> If you want step-by-step instructions for writing cmdlets, see [Tutorials for Writing Cmdlets](./tutorials-for-writing-cmdlets.md).
11+
> If you want step-by-step instructions for writing cmdlets, see [Tutorials for Writing Cmdlets][12].
1212
1313
## In This Section
1414

15-
[How to Write a Simple Cmdlet](./how-to-write-a-simple-cmdlet.md)
16-
This example shows the basic structure of cmdlet code.
17-
18-
[How to Declare Cmdlet Parameters](./how-to-declare-cmdlet-parameters.md)
19-
This example shows how to declare the different types of parameters.
20-
21-
[How to Declare Parameter Sets](./how-to-declare-parameter-sets.md)
22-
This example shows how to declare sets of parameters that can change the action a cmdlet performs.
23-
24-
[How to Validate Parameter Input](./how-to-validate-parameter-input.md)
25-
These examples show how to validate parameter input.
26-
27-
[How to Declare Dynamic Parameters](./how-to-declare-dynamic-parameters.md)
28-
This example shows how to declare a parameter that is added at runtime.
29-
30-
[How to Invoke Scripts Within a Cmdlet](./how-to-invoke-scripts-within-a-cmdlet.md)
31-
This example shows how to invoke a script that is supplied to a cmdlet.
32-
33-
[How To Override Input Processing Methods](./how-to-override-input-processing-methods.md)
34-
These examples show the basic structure used to override the BeginProcessing, ProcessRecord, and EndProcessing methods.
35-
36-
[How to Support ShouldProcess Calls](./how-to-request-confirmations.md)
37-
This example shows how the [System.Management.Automation.Cmdlet.ShouldProcess](/dotnet/api/System.Management.Automation.Cmdlet.ShouldProcess) and [System.Management.Automation.Cmdlet.ShouldContinue](/dotnet/api/System.Management.Automation.Cmdlet.ShouldContinue) methods should be called from within a cmdlet.
38-
39-
[How to Support Transactions](./how-to-support-transactions.md)
40-
This example shows how to indicate that the cmdlet supports transactions and how to implement the action that is taken when the cmdlet is used within a transaction.
41-
42-
[How to Support Jobs](./how-to-support-jobs.md)
43-
This example shows how to support jobs when you write cmdlets.
44-
45-
[How to Invoke a Cmdlet From Within a Cmdlet](./how-to-invoke-a-cmdlet-from-within-a-cmdlet.md)
46-
This example shows how to invoke a cmdlet from within another cmdlet, which allows you to add the functionality of the invoked cmdlet to the cmdlet you are developing.
15+
- [How to Write a Simple Cmdlet][11] - This example shows the basic structure of cmdlet code.
16+
- [How to Declare Cmdlet Parameters][01] - This example shows how to declare the different types of
17+
parameters.
18+
- [How to Declare Parameter Sets][03] - This example shows how to declare sets of parameters that
19+
can change the action a cmdlet performs.
20+
- [How to Validate Parameter Input][10] - These examples show how to validate parameter input.
21+
- [How to Declare Dynamic Parameters][02] - This example shows how to declare a parameter that is
22+
added at runtime.
23+
- [How to Invoke Scripts Within a Cmdlet][05] - This example shows how to invoke a script that is
24+
supplied to a cmdlet.
25+
- [How To Override Input Processing Methods][06] - These examples show the basic structure used to
26+
override the BeginProcessing, ProcessRecord, and EndProcessing methods.
27+
- [How to Support ShouldProcess Calls][07] - This example shows how the
28+
[System.Management.Automation.Cmdlet.ShouldProcess][15] and
29+
[System.Management.Automation.Cmdlet.ShouldContinue][14] methods should be called from within a
30+
cmdlet.
31+
- [How to Support Transactions][09] - This example shows how to indicate that the cmdlet supports
32+
transactions and how to implement the action that is taken when the cmdlet is used within a
33+
transaction.
34+
- [How to Support Transactions][09] - This example shows how to indicate that the cmdlet supports
35+
transactions and how to implement the action that is taken when the cmdlet is used within a
36+
transaction.
37+
- [How to Support Jobs][08] - This example shows how to support jobs when you write cmdlets.
38+
- [How to Invoke a Cmdlet From Within a Cmdlet][04] - This example shows how to invoke a cmdlet from
39+
within another cmdlet, which allows you to add the functionality of the invoked cmdlet to the
40+
cmdlet you are developing.
4741

4842
## See Also
4943

50-
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)
44+
[Writing a Windows PowerShell Cmdlet][13]
45+
46+
<!-- link references -->
47+
[01]: ./how-to-declare-cmdlet-parameters.md
48+
[02]: ./how-to-declare-dynamic-parameters.md
49+
[03]: ./how-to-declare-parameter-sets.md
50+
[04]: ./how-to-invoke-a-cmdlet-from-within-a-cmdlet.md
51+
[05]: ./how-to-invoke-scripts-within-a-cmdlet.md
52+
[06]: ./how-to-override-input-processing-methods.md
53+
[07]: ./requesting-confirmation-from-cmdlets.md
54+
[08]: ./how-to-support-jobs.md
55+
[09]: ./how-to-support-transactions.md
56+
[10]: ./how-to-validate-parameter-input.md
57+
[11]: ./how-to-write-a-simple-cmdlet.md
58+
[12]: ./tutorials-for-writing-cmdlets.md
59+
[13]: ./writing-a-windows-powershell-cmdlet.md
60+
[14]: /dotnet/api/System.Management.Automation.Cmdlet.ShouldContinue
61+
[15]: /dotnet/api/System.Management.Automation.Cmdlet.ShouldProcess

0 commit comments

Comments
 (0)