1
1
---
2
- ms.date : 06 /09/2017
2
+ ms.date : 09 /09/2019
3
3
schema : 2.0.0
4
4
locale : en-us
5
5
keywords : powershell,cmdlet
6
6
title : about_Language_Modes
7
7
---
8
-
9
8
# About Language Modes
10
9
11
10
## SHORT DESCRIPTION
12
-
13
11
Explains language modes and their effect on PowerShell sessions.
14
12
15
13
## LONG DESCRIPTION
@@ -35,7 +33,7 @@ particular session configuration have the language mode of the session
35
33
configuration.
36
34
37
35
All PowerShell sessions have a language mode, including PSSessions that you
38
- create by using the New-PSSession cmdlet, temporary sessions that use the
36
+ create by using the ` New-PSSession ` cmdlet, temporary sessions that use the
39
37
ComputerName parameter, and the default sessions that appear when you start
40
38
PowerShell.
41
39
@@ -51,47 +49,49 @@ This section describes the language modes in PowerShell sessions.
51
49
52
50
#### FULL LANGUAGE (FullLanguage)
53
51
54
- The FullLanguage language mode permits all language elements in the session.
52
+ The FullLanguage mode permits all language elements in the session.
55
53
FullLanguage is the default language mode for default sessions on all versions
56
54
of Windows except for Windows RT.
57
55
58
56
#### RESTRICTED LANGUAGE (RestrictedLanguage)
59
57
60
- In RestrictedLanguage language mode, users may run commands (cmdlets,
61
- functions, CIM commands, and workflows) but are not permitted to use script
62
- blocks.
58
+ In RestrictedLanguage mode, users may run commands (cmdlets, functions, CIM
59
+ commands, and workflows) but are not permitted to use script blocks.
63
60
64
61
By default, only the following variables are permitted in RestrictedLanguage
65
- language mode:
62
+ mode:
66
63
67
- - \ $ PSCulture
68
- - \ $ PSUICulture
69
- - \ $ True
70
- - \ $ False
71
- - \ $ Null.
64
+ - ` $PSCulture `
65
+ - ` $PSUICulture `
66
+ - ` $True `
67
+ - ` $False `
68
+ - ` $Null `
72
69
73
70
Only the following comparison operators are permitted:
74
71
75
- - -eq (equal)
76
- - -gt (greater-than)
77
- - -lt (less-than)
72
+ - ` -eq ` (equal)
73
+ - ` -gt ` (greater-than)
74
+ - ` -lt ` (less-than)
78
75
79
76
Assignment statements, property references, and method calls are not
80
77
permitted.
81
78
82
79
#### NO LANGUAGE (NoLanguage)
83
80
84
- In NoLanguage language mode, users may run commands, but they cannot use any
85
- language elements.
81
+ NoLanguage mode can only be used through the API. NoLanguage mode means no
82
+ script text of any form is permitted. This precludes the use of the
83
+ ** AddScript()** method which sends fragments of PowerShell script to be parsed
84
+ and executed. You can only use ** AddCommand()** and ** AddParameter()** which
85
+ don't go through the parser.
86
86
87
87
#### CONSTRAINED LANGUAGE (Constrained Language)
88
88
89
- The ConstrainedLanguage language mode permits all Windows cmdlets and all
90
- PowerShell language elements, but it limits permitted types.
89
+ The ConstrainedLanguage mode permits all cmdlets and all PowerShell language
90
+ elements, but it limits permitted types.
91
91
92
- ConstrainedLanguage language mode is designed to support User Mode Code
93
- Integrity (UMCI) on Windows RT. It is the only supported language mode on
94
- Windows RT, but it is available on all supported systems.
92
+ ConstrainedLanguage mode is designed to support User Mode Code Integrity (UMCI)
93
+ on Windows RT. It is the only supported language mode on Windows RT, but it is
94
+ available on all supported systems.
95
95
96
96
UMCI protects ARM devices by allowing only Microsoft-signed and
97
97
Microsoft-certified apps to be installed on Windows RT-based devices.
@@ -110,37 +110,35 @@ The features of ConstrainedLanguage mode are as follows:
110
110
modules export run in the session.
111
111
112
112
- In PowerShell Workflow, you can write and run script workflows (workflows
113
- written in the PowerShell language). XAML-based workflows are not
114
- supported and you cannot run XAML in a script workflow, such as by using
115
- " Invoke-Expression -Language XAML" . Also, workflows cannot call other
113
+ written in the PowerShell language). XAML-based workflows are not supported
114
+ and you cannot run XAML in a script workflow, such as by using
115
+ ` Invoke-Expression -Language XAML ` . Also, workflows cannot call other
116
116
workflows, although nested workflows are permitted.
117
117
118
- - The Add-Type cmdlet can load signed assemblies, but it cannot load
118
+ - The ` Add-Type ` cmdlet can load signed assemblies, but it cannot load
119
119
arbitrary C# code or Win32 APIs.
120
120
121
- - The New-Object cmdlet can be used only on allowed types (listed below).
121
+ - The ` New-Object ` cmdlet can be used only on allowed types (listed below).
122
122
123
- - Only allowed types (listed below) can be used in PowerShell. Other types
124
- are not permitted.
123
+ - Only allowed types (listed below) can be used in PowerShell. Other types are
124
+ not permitted.
125
125
126
- - Type conversion is permitted, but only when the result is an allowed
127
- type.
126
+ - Type conversion is permitted, but only when the result is an allowed type.
128
127
129
128
- Cmdlet parameters that convert string input to types work only when the
130
129
resulting type is an allowed type.
131
130
132
- - The ToString() method and the .NET methods of allowed types (listed
131
+ - The ** ToString()** method and the .NET methods of allowed types (listed
133
132
below) can be invoked. Other methods cannot be invoked.
134
133
135
- - Users can get all properties of allowed types. Users can set the values
136
- of properties only on Core types.
134
+ - Users can get all properties of allowed types. Users can set the values of
135
+ properties only on Core types. Only the following COM objects are permitted:
137
136
138
- - Only the following COM objects are permitted.
139
- - Scripting.Dictionary
140
- - Scripting.FileSystemObject
141
- - VBScript.RegExp
137
+ - ** Scripting.Dictionary**
138
+ - ** Scripting.FileSystemObject**
139
+ - ** VBScript.RegExp**
142
140
143
- The following types are permitted in ConstrainedLanguage language mode. Users
141
+ The following types are permitted in ConstrainedLanguage mode. Users
144
142
can get properties, invoke methods, and convert objects to these types.
145
143
146
144
Allowed Types:
@@ -200,7 +198,7 @@ the session configuration has a LanguageMode property. You can find the
200
198
language mode by getting the value of the LanguageMode property.
201
199
202
200
``` powershell
203
- PS C:\ > (Get-PSSessionConfiguration -Name Test).LanguageMode
201
+ PS> (Get-PSSessionConfiguration -Name Test).LanguageMode
204
202
FullLanguage
205
203
```
206
204
@@ -217,15 +215,15 @@ state.
217
215
For example:
218
216
219
217
``` powershell
220
- PS C: > $ExecutionContext.SessionState.LanguageMode
218
+ PS> $ExecutionContext.SessionState.LanguageMode
221
219
ConstrainedLanguage
222
220
```
223
221
224
- However, in sessions with RestrictedLanguage and NoLanguage language modes,
222
+ However, in sessions with RestrictedLanguage and NoLanguage modes,
225
223
you cannot use the dot method to get property values. Instead, the error
226
224
message reveals the language mode.
227
225
228
- When you run the \ $ ExecutionContext.SessionState.LanguageMode command in a
226
+ When you run the ` $ExecutionContext.SessionState.LanguageMode ` command in a
229
227
RestrictedLanguage session, PowerShell returns the
230
228
PropertyReferenceNotSupportedInDataSection and
231
229
VariableReferenceNotSupportedInDataSection error messages.
@@ -236,11 +234,11 @@ VariableReferenceNotSupportedInDataSection error messages.
236
234
referenced in restricted language mode or a Data section is being
237
235
referenced.
238
236
239
- When you run the \ $ ExecutionContext.SessionState.LanguageMode command in a
237
+ When you run the ` $ExecutionContext.SessionState.LanguageMode ` command in a
240
238
NoLanguage session, PowerShell returns the ScriptsNotAllowed error message.
241
239
242
- - ScriptsNotAllowed: The syntax is not supported by this runspace. This
243
- might be because it is in no-language mode.
240
+ - ScriptsNotAllowed: The syntax is not supported by this runspace. This might
241
+ be because it is in no-language mode.
244
242
245
243
## KEYWORDS
246
244
@@ -253,4 +251,3 @@ NoLanguage session, PowerShell returns the ScriptsNotAllowed error message.
253
251
254
252
- [ about_Session_Configuration_Files] ( about_Session_Configuration_Files.md )
255
253
- [ about_Session_Configurations] ( about_Session_Configurations.md )
256
- - [ about_Windows_RT] ( about_Windows_RT.md )
0 commit comments