You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reference/docs-conceptual/developer/cmdlet/examples-of-cmdlet-code.md
+45-34Lines changed: 45 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,43 +8,54 @@ title: Examples of Cmdlet Code
8
8
This section contains examples of cmdlet code that you can use to start writing your own cmdlets.
9
9
10
10
> [!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].
12
12
13
13
## In This Section
14
14
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.
47
41
48
42
## See Also
49
43
50
-
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)
0 commit comments