11---
22description : Explains Data sections, which isolate text strings and other read-only data from script logic.
33Locale : en-US
4- ms.date : 04/23/2019
4+ ms.date : 01/09/2025
55online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_data_sections?view=powershell-5.1&WT.mc_id=ps-gethelp
66schema : 2.0.0
77title : 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
1314data 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
2021restricted to a specified subset of the PowerShell scripting language.
2122
2223Separating data from code logic makes it easier to identify and manage both
2324logic and data. It lets you have separate string resource files for text, such
2425as error messages and Help strings. It also isolates the code logic, which
2526facilitates 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
3939DATA [<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
4545is 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
7474enclose the key-value pairs in single-quoted or double-quoted strings or in
7575single-quoted or double-quoted here-strings. However, strings that contain
7676variables 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
8787cmdlet 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
102102notation 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 `
105105command that converts the here-string into a hash table. The hash table is
106106assigned 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
130131DATA 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
0 commit comments