Skip to content

Commit 07b76b2

Browse files
authored
Merge pull request #11656 from MicrosoftDocs/main
1/9/2025 PM Publish
2 parents 6e21017 + 553d099 commit 07b76b2

File tree

21 files changed

+1123
-1109
lines changed

21 files changed

+1123
-1109
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Comment_Based_Help.md

Lines changed: 141 additions & 155 deletions
Large diffs are not rendered by default.

reference/5.1/Microsoft.PowerShell.Core/About/about_Data_Sections.md

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
---
22
description: Explains Data sections, which isolate text strings and other read-only data from script logic.
33
Locale: en-US
4-
ms.date: 04/23/2019
4+
ms.date: 01/09/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_data_sections?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Data_Sections
88
---
99
# about_Data_Sections
1010

1111
## Short description
12-
Explains Data sections, which isolate text strings and other read-only
12+
13+
Explains `DATA` sections, which isolate text strings and other read-only
1314
data from script logic.
1415

1516
## Long description
1617

17-
Scripts that are designed for PowerShell can have one or more Data sections
18-
that contain only data. You can include one or more Data sections in any
19-
script, function, or advanced function. The content of the Data section is
18+
Scripts that are designed for PowerShell can have one or more `DATA` sections
19+
that contain only data. You can include one or more `DATA` sections in any
20+
script, function, or advanced function. The content of the `DATA` section is
2021
restricted to a specified subset of the PowerShell scripting language.
2122

2223
Separating data from code logic makes it easier to identify and manage both
2324
logic and data. It lets you have separate string resource files for text, such
2425
as error messages and Help strings. It also isolates the code logic, which
2526
facilitates security and validation tests.
2627

27-
In PowerShell, the Data section is used to support script internationalization.
28-
You can use Data sections to make it easier to isolate, locate, and process
29-
strings that will be translated into many user interface (UI) languages.
28+
In PowerShell, you can use the `DATA` section to support script
29+
internationalization. You can use `DATA` sections to make it easier to isolate,
30+
locate, and process strings that can be translated into other languages.
3031

31-
The Data section is a PowerShell 2.0 feature. Scripts with Data sections will
32-
not run in PowerShell 1.0 without revision.
32+
The `DATA` section was added in PowerShell 2.0 feature.
3333

3434
### Syntax
3535

36-
The syntax for a Data section is as follows:
36+
The syntax for a `DATA` section is as follows:
3737

38-
```
38+
```Syntax
3939
DATA [<variable-name>] [-supportedCommand <cmdlet-name>] {
4040
<Permitted content>
4141
}
4242
```
4343

44-
The Data keyword is required. It is not case-sensitive. The permitted content
44+
The `DATA` keyword is required. It isn't case-sensitive. The permitted content
4545
is limited to the following elements:
4646

4747
- All PowerShell operators, except `-match`
@@ -65,28 +65,28 @@ is limited to the following elements:
6565
'@
6666
```
6767

68-
- Cmdlets that are permitted in a Data section. By default, only the
68+
- Cmdlets that are permitted in a `DATA` section. By default, only the
6969
`ConvertFrom-StringData` cmdlet is permitted.
70-
- Cmdlets that you permit in a Data section by using the `-SupportedCommand`
70+
- Cmdlets that you permit in a `DATA` section by using the `-SupportedCommand`
7171
parameter.
7272

73-
When you use the `ConvertFrom-StringData` cmdlet in a Data section, you can
73+
When you use the `ConvertFrom-StringData` cmdlet in a `DATA` section, you can
7474
enclose the key-value pairs in single-quoted or double-quoted strings or in
7575
single-quoted or double-quoted here-strings. However, strings that contain
7676
variables and subexpressions must be enclosed in single-quoted strings or in
77-
single-quoted here-strings so that the variables are not expanded and the
78-
subexpressions are not executable.
77+
single-quoted here-strings so that the variables aren't expanded and the
78+
subexpressions aren't executable.
7979

8080
### -SupportedCommand
8181

82-
The `-SupportedCommand` parameter allows you to indicate that a cmdlet or
83-
function generates only data. It is designed to allow users to include cmdlets
84-
and functions in a data section that they have written or tested.
82+
The **SupportedCommand** parameter allows you to indicate that a cmdlet or
83+
function generates only data. It's designed to allow users to include cmdlets
84+
and functions in a `DATA` section that they have written or tested.
8585

86-
The value of `-SupportedCommand` is a comma-separated list of one or more
86+
The value of **SupportedCommand** is a comma-separated list of one or more
8787
cmdlet or function names.
8888

89-
For example, the following data section includes a user-written cmdlet,
89+
For example, the following `DATA` section includes a user-written cmdlet,
9090
`Format-Xml`, that formats data in an XML file:
9191

9292
```powershell
@@ -96,16 +96,16 @@ DATA -supportedCommand Format-Xml
9696
}
9797
```
9898

99-
### Using a Data Section
99+
### Using a `DATA` Section
100100

101-
To use the content of a Data section, assign it to a variable and use variable
101+
To use the content of a `DATA` section, assign it to a variable and use variable
102102
notation to access the content.
103103

104-
For example, the following data section contains a `ConvertFrom-StringData`
104+
For example, the following `DATA` section contains a `ConvertFrom-StringData`
105105
command that converts the here-string into a hash table. The hash table is
106106
assigned to the `$TextMsgs` variable.
107107

108-
The `$TextMsgs` variable is not part of the data section.
108+
The `$TextMsgs` variable isn't part of the `DATA` section.
109109

110110
```powershell
111111
$TextMsgs = DATA {
@@ -124,7 +124,8 @@ $TextMsgs.Text001
124124
$TextMsgs.Text002
125125
```
126126

127-
Alternately, you can put the variable name in the definition of the Data section. For example:
127+
Alternately, you can put the variable name in the definition of the `DATA`
128+
section. For example:
128129

129130
```powershell
130131
DATA TextMsgs {
@@ -200,12 +201,23 @@ DATA -supportedCommand Format-XML {
200201

201202
## See also
202203

203-
- [about_Automatic_Variables](about_Automatic_Variables.md)
204-
- [about_Comparison_Operators](about_Comparison_Operators.md)
205-
- [about_Hash_Tables](about_Hash_Tables.md)
206-
- [about_If](about_If.md)
207-
- [about_Operators](about_Operators.md)
208-
- [about_Quoting_Rules](about_Quoting_Rules.md)
209-
- [about_Script_Internationalization](about_Script_Internationalization.md)
210-
- [ConvertFrom-StringData](xref:Microsoft.PowerShell.Utility.ConvertFrom-StringData)
211-
- [Import-LocalizedData](xref:Microsoft.PowerShell.Utility.Import-LocalizedData)
204+
- [about_Automatic_Variables][01]
205+
- [about_Comparison_Operators][02]
206+
- [about_Hash_Tables][03]
207+
- [about_If][04]
208+
- [about_Operators][05]
209+
- [about_Quoting_Rules][06]
210+
- [about_Script_Internationalization][07]
211+
- [ConvertFrom-StringData][08]
212+
- [Import-LocalizedData][09]
213+
214+
<!-- link references -->
215+
[01]: about_Automatic_Variables.md
216+
[02]: about_Comparison_Operators.md
217+
[03]: about_Hash_Tables.md
218+
[04]: about_If.md
219+
[05]: about_Operators.md
220+
[06]: about_Quoting_Rules.md
221+
[07]: about_Script_Internationalization.md
222+
[08]: xref:Microsoft.PowerShell.Utility.ConvertFrom-StringData
223+
[09]: xref:Microsoft.PowerShell.Utility.Import-LocalizedData

reference/5.1/Microsoft.PowerShell.Core/About/about_Split.md

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to use the Split operator to split one or more strings into substrings.
33
Locale: en-US
4-
ms.date: 03/30/2021
4+
ms.date: 01/09/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Split
@@ -161,8 +161,24 @@ Vanilla
161161
Strawberry-Blueberry
162162
```
163163

164-
Negative values are ignored.
164+
Negative values return the amount of substrings requested starting
165+
from the end of the input string.
165166

167+
> [!NOTE]
168+
> Support for negative values was added in PowerShell 7.
169+
170+
```powershell
171+
$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
172+
$c -split ",", -5
173+
```
174+
175+
```Output
176+
Mercury,Venus,Earth,Mars
177+
Jupiter
178+
Saturn
179+
Uranus
180+
Neptune
181+
```
166182

167183
### \<ScriptBlock\>
168184

@@ -216,26 +232,17 @@ The RegexMatch options are:
216232
SimpleMatch.
217233
- **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit
218234
operator is specified.
219-
- **CultureInvariant**: Ignores cultural differences in language
220-
when evaluating the delimiter. Valid only with RegexMatch.
221-
- **IgnorePatternWhitespace**: Ignores unescaped whitespace and
222-
comments marked with the number sign (#). Valid only with
223-
RegexMatch.
224-
- **Multiline**: Multiline mode forces `^` and `$` to match the beginning
225-
end of every line instead of the beginning and end of the input string.
226-
- **Singleline**: Singleline mode treats the input string as a *SingleLine*.
227-
It forces the `.` character to match every character (including newlines),
235+
- **CultureInvariant**: Ignores cultural differences in language when
236+
evaluating the delimiter. Valid only with RegexMatch.
237+
- **IgnorePatternWhitespace**: Ignores unescaped whitespace and comments marked
238+
with the hash character (`#`). Valid only with RegexMatch.
239+
- **Multiline**: Multiline mode forces `^` and `$` to match the beginning end
240+
of every line instead of the beginning and end of the input string.
241+
- **Singleline**: Singleline mode treats the input string as a *SingleLine*. It
242+
forces the `.` character to match every character (including newlines),
228243
instead of matching every character EXCEPT the newline `\n`.
229-
- **ExplicitCapture**: Ignores non-named match groups so that only
230-
explicit capture groups are returned in the result list. Valid
231-
only with RegexMatch.
232-
233-
> [!NOTE]
234-
> SingleLine is the default behavior. Singleline and Multiline
235-
> cannot be used together with the options parameter. This was resolved in
236-
> PowerShell 6.0.
237-
> The work around is by using *Mode-Modifiers* in your regular expression.
238-
> You can read more about mode modifiers in [Regular Expression Options](/dotnet/standard/base-types/regular-expression-options)
244+
- **ExplicitCapture**: Ignores non-named match groups so that only explicit
245+
capture groups are returned in the result list. Valid only with RegexMatch.
239246

240247
## UNARY and BINARY SPLIT OPERATORS
241248

@@ -390,6 +397,19 @@ b
390397
c,d,e,f,g,h
391398
```
392399

400+
The following statement splits a string into three substrings
401+
starting from the end of the string.
402+
403+
```powershell
404+
"a,b,c,d,e,f,g,h" -split ",", -3
405+
```
406+
407+
```Output
408+
a,b,c,d,e,f
409+
g
410+
h
411+
```
412+
393413
The following statement splits two strings into three substrings.
394414
(The limit is applied to each string independently.)
395415

@@ -423,7 +443,7 @@ $a = @'
423443
$a -split "^\d", 0, "multiline"
424444
```
425445

426-
```output
446+
```Output
427447
428448
The first line.
429449

reference/5.1/Microsoft.PowerShell.Utility/ConvertFrom-StringData.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 12/12/2022
6-
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-stringdata?view=powershell-5.1&WT.mc_id=ps-gethelp
5+
ms.date: 01/09/2025
6+
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-stringdata?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: ConvertFrom-StringData
99
---
@@ -36,7 +36,7 @@ machine translation tools. That is, the cmdlet can interpret backslashes (`\`) a
3636
in the string data by using the
3737
[Regex.Unescape Method](/dotnet/api/system.text.regularexpressions.regex.unescape), instead of the
3838
PowerShell backtick character (`` ` ``) that would normally signal the end of a line in a script.
39-
Inside the here-string, the backtick character does not work. You can also preserve a literal
39+
Inside the here-string, the backtick character doesn't work. You can also preserve a literal
4040
backslash in your results by escaping it with a preceding backslash, like this: `\\`. Unescaped
4141
backslash characters, such as those that are commonly used in file paths, can render as illegal
4242
escape sequences in your results.
@@ -46,22 +46,22 @@ escape sequences in your results.
4646
### Example 1: Convert a single-quoted here-string to a hash table
4747

4848
This example converts a single-quoted here-string of user messages into a hash table. In a
49-
single-quoted string, values are not substituted for variables and expressions are not evaluated.
49+
single-quoted string, values aren't substituted for variables and expressions aren't evaluated.
5050
The `ConvertFrom-StringData` cmdlet converts the value in the `$Here` variable to a hash table.
5151

5252
```powershell
5353
$Here = @'
5454
Msg1 = The string parameter is required.
5555
Msg2 = Credentials are required for this command.
56-
Msg3 = The specified variable does not exist.
56+
Msg3 = The specified variable doesn't exist.
5757
'@
5858
ConvertFrom-StringData -StringData $Here
5959
```
6060

6161
```Output
6262
Name Value
6363
---- -----
64-
Msg3 The specified variable does not exist.
64+
Msg3 The specified variable doesn't exist.
6565
Msg2 Credentials are required for this command.
6666
Msg1 The string parameter is required.
6767
```
@@ -92,8 +92,8 @@ Name Disks.ps1
9292

9393
The value of the **StringData** parameter is a here-string, instead of a variable that contains a
9494
here-string. Either format is valid. The here-string includes a comment about one of the strings.
95-
`ConvertFrom-StringData` ignores single-line comments, but the `#` character must be the first
96-
non-whitespace character on the line. All characters on the line after the `#` are ignored.
95+
`ConvertFrom-StringData` ignores single-line comments, but the hash character (`#`) must be the
96+
first non-whitespace character on the line.
9797

9898
### Example 3: Convert a string to a hash table
9999

@@ -115,9 +115,9 @@ Top Red
115115
To satisfy the condition that each key-value pair must be on a separate line, the string uses the
116116
PowerShell newline character (`` `n ``) to separate the pairs.
117117

118-
### Example 4: Use ConvertFrom-StringData in the DATA section of a script
118+
### Example 4: Use in the `DATA` section of a script
119119

120-
This example shows a `ConvertFrom-StringData` command used in the **DATA** section of a script.
120+
This example shows a `ConvertFrom-StringData` command used in the `DATA` section of a script.
121121
The statements below the **DATA** section display the text to the user.
122122

123123
```powershell
@@ -138,7 +138,7 @@ Text002 The $MyNotebook variable contains the name of the user's privat
138138
```
139139

140140
Because the text includes variable names, it must be enclosed in a single-quoted string so that the
141-
variables are interpreted literally and not expanded. Variables are not permitted in the **DATA**
141+
variables are interpreted literally and not expanded. Variables aren't permitted in the `DATA`
142142
section.
143143

144144
### Example 5: Use the pipeline operator to pass a string
@@ -151,7 +151,7 @@ and the result in the `$Hash` variable.
151151
$Here = @'
152152
Msg1 = The string parameter is required.
153153
Msg2 = Credentials are required for this command.
154-
Msg3 = The specified variable does not exist.
154+
Msg3 = The specified variable doesn't exist.
155155
'@
156156
$Hash = $Here | ConvertFrom-StringData
157157
$Hash
@@ -160,15 +160,15 @@ $Hash
160160
```Output
161161
Name Value
162162
---- -----
163-
Msg3 The specified variable does not exist.
163+
Msg3 The specified variable doesn't exist.
164164
Msg2 Credentials are required for this command.
165165
Msg1 The string parameter is required.
166166
```
167167

168168
### Example 6: Use escape characters to add new lines and return characters
169169

170170
This example shows the use of escape characters to create new lines and return characters in source
171-
data. The escape sequence `\n` is used to create new lines within a block of text that is associated
171+
data. The escape sequence `\n` is used to create new lines within a block of text that's associated
172172
with a name or item in the resulting hash table.
173173

174174
```powershell
@@ -187,7 +187,7 @@ Value : Let there be some more test made of my metal,
187187
Name : Vincentio
188188
Value : Heaven doth with us as we with torches do,
189189
Not light them for themselves; for if our virtues
190-
Did not go forth of us, 'twere all alike
190+
Didn't go forth of us, 'twere all alike
191191
As if we had them not.
192192
```
193193

@@ -218,10 +218,10 @@ The value of this parameter must be a string that contains one or more key-value
218218
key-value pair must be on a separate line, or each pair must be separated by newline characters
219219
(`` `n ``).
220220

221-
You can include comments in the string, but the comments cannot be on the same line as a key-value
222-
pair. `ConvertFrom-StringData` ignores single-line comments. The `#` character must be the first
223-
non-whitespace character on the line. All characters on the line after the `#` are ignored. The
224-
comments are not included in the hash table.
221+
You can include comments in the string, but the comments can't be on the same line as a key-value
222+
pair. `ConvertFrom-StringData` ignores single-line comments. The hash character (`#`) must be the
223+
first non-whitespace character on the line. All characters on the line after the hash character
224+
(`#`) are ignored. The comments aren't included in the hash table.
225225

226226
A here-string is a string consisting of one or more lines. Quotation marks within the here-string
227227
are interpreted literally as part of the string data. For more information, see

0 commit comments

Comments
 (0)