Skip to content

Commit c4bc861

Browse files
author
Sean Wheeler
authored
Reformatting v6 About_ topics missed in first pass (#2010)
* v6 about scrub missed files * fixing broken links and removing non-v6 content
1 parent 95d4005 commit c4bc861

37 files changed

+3302
-4737
lines changed

reference/6/Microsoft.PowerShell.Core/About/about_Environment_Variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,5 @@ For more information, see [about_Modules](about_Modules.md).
305305

306306
## SEE ALSO
307307

308-
- [Environment (provider)](../../Microsoft.PowerShell.Core/Providers/Environment-Provider.md)
308+
- [Environment (provider)](../Providers/Environment-Provider.md)
309309
- [about_Modules](about_Modules.md)

reference/6/Microsoft.PowerShell.Core/About/about_For.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ all the values in an array, consider using a Foreach statement.
2525
The following shows the For statement syntax.
2626

2727
```powershell
28-
for (>init>; <condition>; <repeat>)
28+
for (<init>; <condition>; <repeat>)
2929
{<statement list>}
3030
```
3131

Lines changed: 134 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,77 @@
11
---
2-
ms.date: 2017-06-09
2+
ms.date: 2018-01-03
33
schema: 2.0.0
44
locale: en-us
55
keywords: powershell,cmdlet
66
title: about_Functions_Advanced_Methods
77
---
88

99
# About Functions Advanced Methods
10-
## about_Functions_Advanced_Methods
1110

11+
## SHORT DESCRIPTION
1212

13-
# SHORT DESCRIPTION
14-
15-
Describes how functions that specify the `CmdletBinding` attribute can use
16-
the methods and properties that are available to compiled cmdlets.
13+
Describes how functions that specify the `CmdletBinding` attribute can use the
14+
methods and properties that are available to compiled cmdlets.
1715

1816
# LONG DESCRIPTION
1917

2018
Functions that specify the `CmdletBinding` attribute can access a number of
21-
methods and properties through the `$pscmdlet` variable. These methods
22-
include the following methods:
19+
methods and properties through the `$pscmdlet` variable. These methods include
20+
the following methods:
2321

2422
- Input-processing methods that compiled cmdlets use to do their work.
25-
2623
- The `ShouldProcess` and `ShouldContinue` methods that are used to get
27-
user feedback before an action is performed.
28-
24+
user feedback before an action is performed.
2925
- The `ThrowTerminatingError` method for generating error records.
30-
3126
- Several Write methods that return different types of output.
3227

3328
All the methods and properties of the `PSCmdlet` class are available to
34-
advanced functions. For more information about these methods and
35-
properties, see `System.Management.Automation.PSCmdlet` in the MSDN
36-
(Microsoft Developer Network) library at
37-
http://go.microsoft.com/fwlink/?LinkId=142139.
38-
39-
# Input Processing Methods
40-
41-
The methods described in this section are referred to as the input
42-
processing methods. For functions, these three methods are represented
43-
by the `Begin`, `Process`, and `End` blocks of the function. Each function
44-
must include one or more of these blocks. The Windows PowerShell runtime
45-
uses the code within these blocks when it is running a function. (These
46-
blocks are also available to functions that do not use the `CmdletBinding`
47-
attribute.)
48-
49-
## Begin
29+
advanced functions. For more information about these methods and properties,
30+
see [`System.Management.Automation.PSCmdlet`](http://go.microsoft.com/fwlink/?LinkId=142139) in the MSDN library.
31+
32+
### Input Processing Methods
33+
34+
The methods described in this section are referred to as the input processing
35+
methods. For functions, these three methods are represented by the `Begin`,
36+
`Process`, and `End` blocks of the function. Each function must include one or
37+
more of these blocks. The Windows PowerShell runtime uses the code within
38+
these blocks when it is running a function. (These blocks are also available
39+
to functions that do not use the `CmdletBinding` attribute.)
40+
41+
#### Begin
42+
5043
This block is used to provide optional one-time preprocessing for the
51-
function. The Windows PowerShell runtime uses the code in this block one
52-
time for each instance of the function in the pipeline.
53-
54-
## Process
55-
This block is used to provide record-by-record processing for the
56-
function. This block might be used any number of times, or not at all,
57-
depending on the input to the function. For example, if the function is
58-
the first command in the pipeline, the `Process` block will be used one
59-
time. If the function is not the first command in the pipeline, the
60-
`Process` block is used one time for every input that the function
61-
receives from the pipeline. If there is no pipeline input, the `Process`
62-
block is not used.
63-
64-
This block must be defined if a function parameter is set to accept
65-
pipeline input. If this block is not defined and the parameter accepts
66-
input from the pipeline, the function will miss the values that are
67-
passed to the function through the pipeline.
44+
function. The Windows PowerShell runtime uses the code in this block one time
45+
for each instance of the function in the pipeline.
46+
47+
#### Process
48+
49+
This block is used to provide record-by-record processing for the function.
50+
This block might be used any number of times, or not at all, depending on the
51+
input to the function. For example, if the function is the first command in
52+
the pipeline, the `Process` block will be used one time. If the function is
53+
not the first command in the pipeline, the `Process` block is used one time
54+
for every input that the function receives from the pipeline. If there is no
55+
pipeline input, the `Process` block is not used.
56+
57+
This block must be defined if a function parameter is set to accept pipeline
58+
input. If this block is not defined and the parameter accepts input from the
59+
pipeline, the function will miss the values that are passed to the function
60+
through the pipeline.
6861

6962
Also, when the function supports confirmation requests (when the
7063
`SupportsShouldProcess` parameter of the Parameter attribute is set to
71-
`$True`), the call to the `ShouldProcess` method must be made from within
72-
the Process block.
64+
`$True`), the call to the `ShouldProcess` method must be made from within the
65+
Process block.
66+
67+
#### End
7368

74-
## End
75-
This block is used to provide optional one-time post-processing for
76-
the function.
69+
This block is used to provide optional one-time post-processing for the
70+
function.
7771

78-
The following example shows the outline of a function that contains a
79-
`Begin` block for one-time preprocessing, a `Process` block for multiple
80-
record processing, and an `End` block for one-time post-processing.
72+
The following example shows the outline of a function that contains a `Begin`
73+
block for one-time preprocessing, a `Process` block for multiple record
74+
processing, and an `End` block for one-time post-processing.
8175

8276
```powershell
8377
Function Test-ScriptCmdlet
@@ -90,119 +84,125 @@ Function Test-ScriptCmdlet
9084
}
9185
```
9286

93-
# Confirmation Methods
87+
### Confirmation Methods
88+
89+
#### ShouldProcess
9490

95-
## ShouldProcess
9691
This method is called to request confirmation from the user before the
97-
function performs an action that would change the system. The function
98-
can continue based on the Boolean value returned by the method. This
99-
method can be called only from within the `Process{}` block of the
100-
function. And, the `CmdletBinding` attribute must declare that the
101-
function supports `ShouldProcess` (as shown in the previous example).
92+
function performs an action that would change the system. The function can
93+
continue based on the Boolean value returned by the method. This method can be
94+
called only from within the `Process{}` block of the function. And, the
95+
`CmdletBinding` attribute must declare that the function supports
96+
`ShouldProcess` (as shown in the previous example).
10297

10398
For more information about this method, see
104-
`System.Management.Automation.Cmdlet.ShouldProcess` in the MSDN library at
105-
http://go.microsoft.com/fwlink/?LinkId=142142.
99+
[`System.Management.Automation.Cmdlet.ShouldProcess`](http://go.microsoft.com/fwlink/?LinkId=142142)
100+
in the MSDN library.
106101

107102
For more information about how to request confirmation, see
108-
"Requesting Confirmation" in the MSDN library at
109-
http://go.microsoft.com/fwlink/?LinkID=136658.
103+
[Requesting Confirmation](http://go.microsoft.com/fwlink/?LinkID=136658)
104+
in the MSDN library.
105+
106+
#### ShouldContinue
110107

111-
## ShouldContinue
112-
This method is called to request a second confirmation message. It
113-
should be called when the `ShouldProcess` method returns `$true`. For more
114-
information about this method, see
115-
`System.Management.Automation.Cmdlet.ShouldContinue` in the MSDN library
116-
at http://go.microsoft.com/fwlink/?LinkId=142143.
108+
This method is called to request a second confirmation message. It should be
109+
called when the `ShouldProcess` method returns `$true`. For more information
110+
about this method, see `System.Management.Automation.Cmdlet.ShouldContinue` in
111+
the MSDN library at http://go.microsoft.com/fwlink/?LinkId=142143.
117112

118-
# Error Methods
113+
### Error Methods
119114

120115
Functions can call two different methods when errors occur. When a
121-
nonterminating error occurs, the function should call the `WriteError`
122-
method, which is described in the "Write Methods" section. When a
123-
terminating error occurs and the function cannot continue, it should call
124-
the `ThrowTerminatingError` method. You can also use the `Throw` statement for
116+
nonterminating error occurs, the function should call the `WriteError` method,
117+
which is described in the "Write Methods" section. When a terminating error
118+
occurs and the function cannot continue, it should call the
119+
`ThrowTerminatingError` method. You can also use the `Throw` statement for
125120
terminating errors and the `Write-Error` cmdlet for nonterminating errors.
126121

127-
For more information, see `System.Management.Automation.Cmdlet.ThrowTerminatingError`
128-
in the MSDN libray at
129-
http://go.microsoft.com/fwlink/?LinkId=142144.
122+
For more information, see
123+
[`System.Management.Automation.Cmdlet.ThrowTerminatingError`](http://go.microsoft.com/fwlink/?LinkId=142144)
124+
in the MSDN libray.
130125

131-
# Write Methods
126+
### Write Methods
132127

133-
A function can call the following methods to return different types of
134-
output. Notice that not all the output goes to the next command in the
135-
pipeline. You can also use the various Write cmdlets, such as
136-
Write-Error.
128+
A function can call the following methods to return different types of output.
129+
Notice that not all the output goes to the next command in the pipeline. You
130+
can also use the various Write cmdlets, such as Write-Error.
131+
132+
#### WriteCommandDetail
137133

138-
## WriteCommandDetail
139134
For information about the `WriteCommandDetails` method, see
140-
`System.Management.Automation.Cmdlet.WriteCommandDetail` in the MSDN
141-
library at http://go.microsoft.com/fwlink/?LinkId=142155.
142-
143-
## WriteDebug
144-
To provide information that can be used to troubleshoot a function,
145-
make the function call the `WriteDebug` method. This displays debug
146-
messages to the user. For more information, see
147-
`System.Management.Automation.Cmdlet.WriteDebug` in the MSDN library
148-
at http://go.microsoft.com/fwlink/?LinkId=142156.
149-
150-
## WriteError
151-
Functions should call this method when nonterminating errors occur and
152-
the function is designed to continue processing records. For more
153-
information, see `System.Management.Automation.Cmdlet.WriteError` in the
154-
MSDN library at http://go.microsoft.com/fwlink/?LinkId=142157.
135+
[`System.Management.Automation.Cmdlet.WriteCommandDetail`](http://go.microsoft.com/fwlink/?LinkId=142155)
136+
in the MSDN library.
137+
138+
#### WriteDebug
139+
140+
To provide information that can be used to troubleshoot a function, make the
141+
function call the `WriteDebug` method. This displays debug messages to the
142+
user. For more information, see
143+
[`System.Management.Automation.Cmdlet.WriteDebug`](http://go.microsoft.com/fwlink/?LinkId=142156)
144+
in the MSDN library.
145+
146+
#### WriteError
147+
148+
Functions should call this method when nonterminating errors occur and the
149+
function is designed to continue processing records. For more information, see
150+
[`System.Management.Automation.Cmdlet.WriteError`](http://go.microsoft.com/fwlink/?LinkId=142157)
151+
in the MSDN library.
155152

156153
Note: If a terminating error occurs, the function should call the
157154
`ThrowTerminatingError` method.
158155

159-
## WriteObject
160-
This method allows the function to send an object to the next command in
161-
the pipeline. In most cases, this is the method to use when the function
162-
returns data. For more information, see
163-
`System.Management.Automation.PSCmdlet.WriteObject` in the MSDN library at
164-
http://go.microsoft.com/fwlink/?LinkId=142158.
165-
166-
## WriteProgress
167-
For functions whose actions take a long time to complete, this method
168-
allows the function to call the `WriteProgress` method so that progress
169-
information is displayed. For example, you can display the percent
170-
completed. For more information, see
171-
`System.Management.Automation.PSCmdlet.WriteProgress` in the MSDN library
172-
at http://go.microsoft.com/fwlink/?LinkId=142160.
173-
174-
## WriteVerbose
175-
To provide detailed information about what the function is doing, make
176-
the function call the `WriteVerbose` method to display verbose messages to
177-
the user. By default, verbose messages are not displayed. For more
178-
information, see `System.Management.Automation.PSCmdlet.WriteVerbose`
179-
in the MSDN library at http://go.microsoft.com/fwlink/?LinkId=142162.
180-
181-
## WriteWarning
182-
To provide information about conditions that may cause unexpected
183-
results, make the function call the WriteWarning method to display
184-
warning messages to the user. By default, warning messages are displayed.
185-
For more information, see
186-
`System.Management.Automation.PSCmdlet.WriteWarning` in the MSDN library
187-
at http://go.microsoft.com/fwlink/?LinkId=142164.
156+
#### WriteObject
157+
158+
This method allows the function to send an object to the next command in the
159+
pipeline. In most cases, this is the method to use when the function returns
160+
data. For more information, see
161+
[`System.Management.Automation.PSCmdlet.WriteObject`](http://go.microsoft.com/fwlink/?LinkId=142158)
162+
in the MSDN library.
163+
164+
#### WriteProgress
165+
166+
For functions whose actions take a long time to complete, this method allows
167+
the function to call the `WriteProgress` method so that progress information
168+
is displayed. For example, you can display the percent completed. For more
169+
information, see [`System.Management.Automation.PSCmdlet.WriteProgress`](http://go.microsoft.com/fwlink/?LinkId=142160)
170+
in the MSDN library.
171+
172+
#### WriteVerbose
173+
174+
To provide detailed information about what the function is doing, make the
175+
function call the `WriteVerbose` method to display verbose messages to the
176+
user. By default, verbose messages are not displayed. For more information,
177+
see
178+
[`System.Management.Automation.PSCmdlet.WriteVerbose`](http://go.microsoft.com/fwlink/?LinkId=142162)
179+
in the MSDN library.
180+
181+
#### WriteWarning
182+
183+
To provide information about conditions that may cause unexpected results,
184+
make the function call the WriteWarning method to display warning messages to
185+
the user. By default, warning messages are displayed. For more information,
186+
see [`System.Management.Automation.PSCmdlet.WriteWarning`](http://go.microsoft.com/fwlink/?LinkId=142164)
187+
in the MSDN library.
188188

189189
Note: You can also display warning messages by configuring the
190190
`WarningPreference` variable or by using the `Verbose` and `Debug`
191191
command-line options.
192192

193-
# Other Methods and Properties
193+
### Other Methods and Properties
194194

195195
For information about the other methods and properties that can be
196196
accessed through the `$PSCmdlet` variable, see
197-
`System.Management.Automation.PSCmdlet` in the MSDN library at
198-
http://go.microsoft.com/fwlink/?LinkId=142139.
197+
[`System.Management.Automation.PSCmdlet`](http://go.microsoft.com/fwlink/?LinkId=142139)
198+
in the MSDN library.
199199

200200
For example, the `ParameterSetName` property allows you to see the parameter
201201
set that is being used. Parameter sets allow you to create a function that
202-
performs different tasks based on the parameters that are specified when
203-
the function is run.
202+
performs different tasks based on the parameters that are specified when the
203+
function is run.
204204

205-
# SEE ALSO
205+
## SEE ALSO
206206

207207
[about_Functions](about_Functions.md)
208208

@@ -213,4 +213,3 @@ the function is run.
213213
[about_Functions_CmdletBindingAttribute](about_Functions_CmdletBindingAttribute.md)
214214

215215
[about_Functions_OutputTypeAttribute](about_Functions_OutputTypeAttribute.md)
216-

0 commit comments

Comments
 (0)