From 1db82fbbae78f4cb0e46d208f947d5f1c63dfa39 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 20:53:56 +0000 Subject: [PATCH 1/6] Remove invalid types from v5.1's core type list The types removed from the core types list (permitted in ConstrainedLanguage mode) are only applicable to PS v6+, so are removed from the Windows PowerShell v5.1 document. Unlike in later versions, [ordered] is not a type (accelerator) in v5.1. --- .../About/about_Language_Modes.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 395440d721ea..3cbea7b692e5 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -230,7 +230,6 @@ Allowed Types: - `[AllowEmptyString]` - `[AllowNull]` - `[ArgumentCompleter]` -- `[ArgumentCompletions]` - `[array]` - `[bigint]` - `[bool]` @@ -249,9 +248,6 @@ Allowed Types: - `[DscLocalConfigurationManager]` - `[DscProperty]` - `[DscResource]` -- `[ExperimentAction]` -- `[Experimental]` -- `[ExperimentalFeature]` - `[float]` - `[guid]` - `[hashtable]` @@ -267,7 +263,6 @@ Allowed Types: - `[NullString]` - `[Object[]]` - `[ObjectSecurity]` -- `[ordered]` - `[OutputType]` - `[Parameter]` - `[PhysicalAddress]` @@ -282,20 +277,15 @@ Allowed Types: - `[regex]` - `[sbyte]` - `[securestring]` -- `[semver]` -- `[short]` - `[single]` - `[string]` - `[SupportsWildcards]` - `[switch]` - `[timespan]` -- `[uint]` - `[uint16]` - `[uint32]` - `[uint64]` -- `[ulong]` - `[uri]` -- `[ushort]` - `[ValidateCount]` - `[ValidateDrive]` - `[ValidateLength]` From 0a928c690b8a85d9d65f26a968f3f286549eb690 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:35:23 +0000 Subject: [PATCH 2/6] Add [ref] special case for ConstrainedLanguage [ref] is found in CoreTypes and is therefore permitted in ConstrainedLanguage mode. However, casting is not permitted and results in a statement-terminating error. Other uses (new() instantiation, in parameter binding, etc) are permitted. --- .../About/about_Language_Modes.md | 9 +++++++-- .../About/about_Language_Modes.md | 9 +++++++-- .../About/about_Language_Modes.md | 9 +++++++-- .../About/about_Language_Modes.md | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 3cbea7b692e5..a54ea240da2a 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -1,7 +1,7 @@ --- description: Explains language modes and their effect on PowerShell sessions. Locale: en-US -ms.date: 10/04/2023 +ms.date: 04/03/2025 no-loc: [FullLanguage, ConstrainedLanguage, RestrictedLanguage, NoLanguage] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -273,7 +273,6 @@ Allowed Types: - `[psobject]` - `[psprimitivedictionary]` - `[PSTypeNameAttribute]` -- `[ref]` - `[regex]` - `[sbyte]` - `[securestring]` @@ -313,6 +312,12 @@ Only the following COM object types are permitted: - `Scripting.FileSystemObject` - `VBScript.RegExp` +Special cases: + +- `[ref]` - Casting an object to type `[ref]` or + `[Management.Automation.PSReference]` is not permitted. Other uses are + permitted. + ### NoLanguage mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 57aee59a21cd..e4464618e4a8 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -1,7 +1,7 @@ --- description: Explains language modes and their effect on PowerShell sessions. Locale: en-US -ms.date: 10/04/2023 +ms.date: 04/03/2025 no-loc: [FullLanguage, ConstrainedLanguage, RestrictedLanguage, NoLanguage] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -277,7 +277,6 @@ Allowed Types: - `[psobject]` - `[psprimitivedictionary]` - `[PSTypeNameAttribute]` -- `[ref]` - `[regex]` - `[sbyte]` - `[securestring]` @@ -323,6 +322,12 @@ Only the following COM object types are permitted: - `Scripting.FileSystemObject` - `VBScript.RegExp` +Special cases: + +- `[ref]` - Casting an object to type `[ref]` or + `[Management.Automation.PSReference]` is not permitted. Other uses are + permitted. + ### NoLanguage mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md index bf113f57fb7c..4419fad8347c 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -1,7 +1,7 @@ --- description: Explains language modes and their effect on PowerShell sessions. Locale: en-US -ms.date: 10/04/2023 +ms.date: 04/03/2025 no-loc: [FullLanguage, ConstrainedLanguage, RestrictedLanguage, NoLanguage] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -277,7 +277,6 @@ Allowed Types: - `[psobject]` - `[psprimitivedictionary]` - `[PSTypeNameAttribute]` -- `[ref]` - `[regex]` - `[sbyte]` - `[securestring]` @@ -323,6 +322,12 @@ Only the following COM object types are permitted: - `Scripting.FileSystemObject` - `VBScript.RegExp` +Special cases: + +- `[ref]` - Casting an object to type `[ref]` or + `[Management.Automation.PSReference]` is not permitted. Other uses are + permitted. + ### NoLanguage mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md index e75e37a8bda1..ebedb3fcee17 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -1,7 +1,7 @@ --- description: Explains language modes and their effect on PowerShell sessions. Locale: en-US -ms.date: 10/04/2023 +ms.date: 04/03/2025 no-loc: [FullLanguage, ConstrainedLanguage, RestrictedLanguage, NoLanguage] online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -277,7 +277,6 @@ Allowed Types: - `[psobject]` - `[psprimitivedictionary]` - `[PSTypeNameAttribute]` -- `[ref]` - `[regex]` - `[sbyte]` - `[securestring]` @@ -323,6 +322,12 @@ Only the following COM object types are permitted: - `Scripting.FileSystemObject` - `VBScript.RegExp` +Special cases: + +- `[ref]` - Casting an object to type `[ref]` or + `[Management.Automation.PSReference]` is not permitted. Other uses are + permitted. + ### NoLanguage mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. From 6d6f7bba6cd8d7aefb6e49812555387e593967f4 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:46:43 +0000 Subject: [PATCH 3/6] Minor formatting changes to about_Language_Modes --- .../About/about_Language_Modes.md | 34 +++++++++++-------- .../About/about_Language_Modes.md | 25 +++++++++----- .../About/about_Language_Modes.md | 25 +++++++++----- .../About/about_Language_Modes.md | 25 +++++++++----- 4 files changed, 68 insertions(+), 41 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md index a54ea240da2a..fd60edff96aa 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -50,6 +50,9 @@ For example: ```powershell $ExecutionContext.SessionState.LanguageMode +``` + +```Output ConstrainedLanguage ``` @@ -57,7 +60,7 @@ However, in sessions with `RestrictedLanguage` and `NoLanguage` modes, you can't use the [member-access operator][02] (`.`) to get property values. Instead, the error message reveals the language mode. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a +When you access `$ExecutionContext.SessionState.LanguageMode` in a `RestrictedLanguage` session, PowerShell returns the **PropertyReferenceNotSupportedInDataSection** and **VariableReferenceNotSupportedInDataSection** error messages. @@ -68,8 +71,9 @@ When you run the `$ExecutionContext.SessionState.LanguageMode` command in a referenced in restricted language mode or a Data section is being referenced. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a -NoLanguage session, PowerShell returns the **ScriptsNotAllowed** error message. +When you access `$ExecutionContext.SessionState.LanguageMode` in a +`NoLanguage` session, PowerShell returns the **ScriptsNotAllowed** error +message. - **ScriptsNotAllowed**: The syntax isn't supported by this runspace. This might be because it's in no-language mode. @@ -82,6 +86,9 @@ language mode by getting the value of the **LanguageMode** property. ```powershell (Get-PSSessionConfiguration -Name Test).LanguageMode +``` + +```Output FullLanguage ``` @@ -117,11 +124,10 @@ application control policy. For example, there are additional restrictions to dot-sourcing and module importing under a policy. When a PowerShell session is started under a policy, it runs in -`ConstrainedLanguage` mode. This mode allows for a usable interactive shell -experience while limiting access to features and APIs that could be abused by a -malicious actor. Users can run cmdlets and native commands and have access to -basic language elements. Access to PowerShell, .NET, and COM APIs is -restricted. +`ConstrainedLanguage` mode. This mode allows users to have a usable interactive +shell experience, running cmdlets and native commands, as well as access to +basic language elements. But the user can't access PowerShell, .NET, or COM +APIs that could be abused by a malicious actor. Any script or script-based module executed in this session runs in `ConstrainedLanguage` mode. However, any script or script-based module allowed @@ -146,13 +152,13 @@ For more information, see [JEA Session configurations][01] and This section describes the language modes in PowerShell sessions. -### FullLanguage mode +### `FullLanguage` mode The `FullLanguage` mode permits all language elements in the session. `FullLanguage` is the default language mode for default sessions on all versions of Windows. -### RestrictedLanguage mode +### `RestrictedLanguage` mode In `RestrictedLanguage` mode, users can run commands (cmdlets, functions, CIM commands, and workflows), but can't use script blocks. This mode is also used @@ -176,7 +182,7 @@ additional variables: - `$PSScriptRoot` - `$PSEdition` - `$EnabledExperimentalFeatures` -- Any environment variables, like `$Env:TEMP` +- Any environment variable, like `$env:TEMP` Only the following comparison operators are permitted: @@ -186,7 +192,7 @@ Only the following comparison operators are permitted: Assignment statements, property references, and method calls aren't permitted. -### ConstrainedLanguage mode +### `ConstrainedLanguage` mode `ConstrainedLanguage` mode is designed to allow basic language elements such as loops, conditionals, string expansion, and access to object properties. The @@ -221,7 +227,7 @@ The features of `ConstrainedLanguage` mode are as follows: The following .NET types are permitted in `ConstrainedLanguage` mode. Users can get properties, invoke methods, and convert objects to these types. -Allowed Types: +Allowed types: - `[adsi]` - `[adsisearcher]` @@ -318,7 +324,7 @@ Special cases: `[Management.Automation.PSReference]` is not permitted. Other uses are permitted. -### NoLanguage mode +### `NoLanguage` mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. You can't run scripts or use variables. You can only run native commands and diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md index e4464618e4a8..2bd9a2434855 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -53,6 +53,9 @@ For example: ```powershell $ExecutionContext.SessionState.LanguageMode +``` + +```Output ConstrainedLanguage ``` @@ -60,7 +63,7 @@ However, in sessions with `RestrictedLanguage` and `NoLanguage` modes, you can't use the [member-access operator][02] (`.`) to get property values. Instead, the error message reveals the language mode. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a +When you access `$ExecutionContext.SessionState.LanguageMode` in a `RestrictedLanguage` session, PowerShell returns the **PropertyReferenceNotSupportedInDataSection** and **VariableReferenceNotSupportedInDataSection** error messages. @@ -71,8 +74,9 @@ When you run the `$ExecutionContext.SessionState.LanguageMode` command in a referenced in restricted language mode or a Data section is being referenced. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a -NoLanguage session, PowerShell returns the **ScriptsNotAllowed** error message. +When you access `$ExecutionContext.SessionState.LanguageMode` in a +`NoLanguage` session, PowerShell returns the **ScriptsNotAllowed** error +message. - **ScriptsNotAllowed**: The syntax isn't supported by this runspace. This might be because it's in no-language mode. @@ -85,6 +89,9 @@ language mode by getting the value of the **LanguageMode** property. ```powershell (Get-PSSessionConfiguration -Name Test).LanguageMode +``` + +```Output FullLanguage ``` @@ -149,13 +156,13 @@ For more information, see [JEA Session configurations][01] and This section describes the language modes in PowerShell sessions. -### FullLanguage mode +### `FullLanguage` mode The `FullLanguage` mode permits all language elements in the session. `FullLanguage` is the default language mode for default sessions on all versions of Windows. -### RestrictedLanguage mode +### `RestrictedLanguage` mode In `RestrictedLanguage` mode, users can run commands (cmdlets, functions, CIM commands, and workflows), but can't use script blocks. This mode is also used @@ -179,7 +186,7 @@ additional variables: - `$PSScriptRoot` - `$PSEdition` - `$EnabledExperimentalFeatures` -- Any environment variables, like `$Env:TEMP` +- Any environment variable, like `$env:TEMP` Only the following comparison operators are permitted: @@ -189,7 +196,7 @@ Only the following comparison operators are permitted: Assignment statements, property references, and method calls aren't permitted. -### ConstrainedLanguage mode +### `ConstrainedLanguage` mode `ConstrainedLanguage` mode is designed to allow basic language elements such as loops, conditionals, string expansion, and access to object properties. The @@ -219,7 +226,7 @@ The features of `ConstrainedLanguage` mode are as follows: The following .NET types are permitted in `ConstrainedLanguage` mode. Users can get properties, invoke methods, and convert objects to these types. -Allowed Types: +Allowed types: - `[adsi]` - `[adsisearcher]` @@ -328,7 +335,7 @@ Special cases: `[Management.Automation.PSReference]` is not permitted. Other uses are permitted. -### NoLanguage mode +### `NoLanguage` mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. You can't run scripts or use variables. You can only run native commands and diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 4419fad8347c..306c3ae48b7d 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -53,6 +53,9 @@ For example: ```powershell $ExecutionContext.SessionState.LanguageMode +``` + +```Output ConstrainedLanguage ``` @@ -60,7 +63,7 @@ However, in sessions with `RestrictedLanguage` and `NoLanguage` modes, you can't use the [member-access operator][02] (`.`) to get property values. Instead, the error message reveals the language mode. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a +When you access `$ExecutionContext.SessionState.LanguageMode` in a `RestrictedLanguage` session, PowerShell returns the **PropertyReferenceNotSupportedInDataSection** and **VariableReferenceNotSupportedInDataSection** error messages. @@ -71,8 +74,9 @@ When you run the `$ExecutionContext.SessionState.LanguageMode` command in a referenced in restricted language mode or a Data section is being referenced. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a -NoLanguage session, PowerShell returns the **ScriptsNotAllowed** error message. +When you access `$ExecutionContext.SessionState.LanguageMode` in a +`NoLanguage` session, PowerShell returns the **ScriptsNotAllowed** error +message. - **ScriptsNotAllowed**: The syntax isn't supported by this runspace. This might be because it's in no-language mode. @@ -85,6 +89,9 @@ language mode by getting the value of the **LanguageMode** property. ```powershell (Get-PSSessionConfiguration -Name Test).LanguageMode +``` + +```Output FullLanguage ``` @@ -149,13 +156,13 @@ For more information, see [JEA Session configurations][01] and This section describes the language modes in PowerShell sessions. -### FullLanguage mode +### `FullLanguage` mode The `FullLanguage` mode permits all language elements in the session. `FullLanguage` is the default language mode for default sessions on all versions of Windows. -### RestrictedLanguage mode +### `RestrictedLanguage` mode In `RestrictedLanguage` mode, users can run commands (cmdlets, functions, CIM commands, and workflows), but can't use script blocks. This mode is also used @@ -179,7 +186,7 @@ additional variables: - `$PSScriptRoot` - `$PSEdition` - `$EnabledExperimentalFeatures` -- Any environment variables, like `$Env:TEMP` +- Any environment variable, like `$env:TEMP` Only the following comparison operators are permitted: @@ -189,7 +196,7 @@ Only the following comparison operators are permitted: Assignment statements, property references, and method calls aren't permitted. -### ConstrainedLanguage mode +### `ConstrainedLanguage` mode `ConstrainedLanguage` mode is designed to allow basic language elements such as loops, conditionals, string expansion, and access to object properties. The @@ -219,7 +226,7 @@ The features of `ConstrainedLanguage` mode are as follows: The following .NET types are permitted in `ConstrainedLanguage` mode. Users can get properties, invoke methods, and convert objects to these types. -Allowed Types: +Allowed types: - `[adsi]` - `[adsisearcher]` @@ -328,7 +335,7 @@ Special cases: `[Management.Automation.PSReference]` is not permitted. Other uses are permitted. -### NoLanguage mode +### `NoLanguage` mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. You can't run scripts or use variables. You can only run native commands and diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md index ebedb3fcee17..f6803a764d66 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -53,6 +53,9 @@ For example: ```powershell $ExecutionContext.SessionState.LanguageMode +``` + +```Output ConstrainedLanguage ``` @@ -60,7 +63,7 @@ However, in sessions with `RestrictedLanguage` and `NoLanguage` modes, you can't use the [member-access operator][02] (`.`) to get property values. Instead, the error message reveals the language mode. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a +When you access `$ExecutionContext.SessionState.LanguageMode` in a `RestrictedLanguage` session, PowerShell returns the **PropertyReferenceNotSupportedInDataSection** and **VariableReferenceNotSupportedInDataSection** error messages. @@ -71,8 +74,9 @@ When you run the `$ExecutionContext.SessionState.LanguageMode` command in a referenced in restricted language mode or a Data section is being referenced. -When you run the `$ExecutionContext.SessionState.LanguageMode` command in a -NoLanguage session, PowerShell returns the **ScriptsNotAllowed** error message. +When you access `$ExecutionContext.SessionState.LanguageMode` in a +`NoLanguage` session, PowerShell returns the **ScriptsNotAllowed** error +message. - **ScriptsNotAllowed**: The syntax isn't supported by this runspace. This might be because it's in no-language mode. @@ -85,6 +89,9 @@ language mode by getting the value of the **LanguageMode** property. ```powershell (Get-PSSessionConfiguration -Name Test).LanguageMode +``` + +```Output FullLanguage ``` @@ -149,13 +156,13 @@ For more information, see [JEA Session configurations][01] and This section describes the language modes in PowerShell sessions. -### FullLanguage mode +### `FullLanguage` mode The `FullLanguage` mode permits all language elements in the session. `FullLanguage` is the default language mode for default sessions on all versions of Windows. -### RestrictedLanguage mode +### `RestrictedLanguage` mode In `RestrictedLanguage` mode, users can run commands (cmdlets, functions, CIM commands, and workflows), but can't use script blocks. This mode is also used @@ -179,7 +186,7 @@ additional variables: - `$PSScriptRoot` - `$PSEdition` - `$EnabledExperimentalFeatures` -- Any environment variables, like `$Env:TEMP` +- Any environment variable, like `$env:TEMP` Only the following comparison operators are permitted: @@ -189,7 +196,7 @@ Only the following comparison operators are permitted: Assignment statements, property references, and method calls aren't permitted. -### ConstrainedLanguage mode +### `ConstrainedLanguage` mode `ConstrainedLanguage` mode is designed to allow basic language elements such as loops, conditionals, string expansion, and access to object properties. The @@ -219,7 +226,7 @@ The features of `ConstrainedLanguage` mode are as follows: The following .NET types are permitted in `ConstrainedLanguage` mode. Users can get properties, invoke methods, and convert objects to these types. -Allowed Types: +Allowed types: - `[adsi]` - `[adsisearcher]` @@ -328,7 +335,7 @@ Special cases: `[Management.Automation.PSReference]` is not permitted. Other uses are permitted. -### NoLanguage mode +### `NoLanguage` mode PowerShell `NoLanguage` mode disables PowerShell scripting language completely. You can't run scripts or use variables. You can only run native commands and From b574f00162c73bfd740b9efa2ca3add5e6fb9717 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:55:27 +0000 Subject: [PATCH 4/6] Add note on Windows-only CoreTypes --- .../About/about_Language_Modes.md | 10 +++++----- .../About/about_Language_Modes.md | 10 +++++----- .../About/about_Language_Modes.md | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 2bd9a2434855..74fef858a52a 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -228,8 +228,8 @@ get properties, invoke methods, and convert objects to these types. Allowed types: -- `[adsi]` -- `[adsisearcher]` +- `[adsi]` (Windows-only) +- `[adsisearcher]` (Windows-only) - `[Alias]` - `[AllowEmptyCollection]` - `[AllowEmptyString]` @@ -316,9 +316,9 @@ Allowed types: - `[version]` - `[void]` - `[WildcardPattern]` -- `[wmi]` -- `[wmiclass]` -- `[wmisearcher]` +- `[wmi]` (Windows-only) +- `[wmiclass]` (Windows-only) +- `[wmisearcher]` (Windows-only) - `[X500DistinguishedName]` - `[X509Certificate]` - `[xml]` diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md index 306c3ae48b7d..f07079946635 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -228,8 +228,8 @@ get properties, invoke methods, and convert objects to these types. Allowed types: -- `[adsi]` -- `[adsisearcher]` +- `[adsi]` (Windows-only) +- `[adsisearcher]` (Windows-only) - `[Alias]` - `[AllowEmptyCollection]` - `[AllowEmptyString]` @@ -316,9 +316,9 @@ Allowed types: - `[version]` - `[void]` - `[WildcardPattern]` -- `[wmi]` -- `[wmiclass]` -- `[wmisearcher]` +- `[wmi]` (Windows-only) +- `[wmiclass]` (Windows-only) +- `[wmisearcher]` (Windows-only) - `[X500DistinguishedName]` - `[X509Certificate]` - `[xml]` diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md index f6803a764d66..a78a133c4772 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -228,8 +228,8 @@ get properties, invoke methods, and convert objects to these types. Allowed types: -- `[adsi]` -- `[adsisearcher]` +- `[adsi]` (Windows-only) +- `[adsisearcher]` (Windows-only) - `[Alias]` - `[AllowEmptyCollection]` - `[AllowEmptyString]` @@ -316,9 +316,9 @@ Allowed types: - `[version]` - `[void]` - `[WildcardPattern]` -- `[wmi]` -- `[wmiclass]` -- `[wmisearcher]` +- `[wmi]` (Windows-only) +- `[wmiclass]` (Windows-only) +- `[wmisearcher]` (Windows-only) - `[X500DistinguishedName]` - `[X509Certificate]` - `[xml]` From 156e650e5d8bbcb52b19fd2c59b0d55fcd1a35e8 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:11:26 +0000 Subject: [PATCH 5/6] Add note on [ordered] caveats in v5.1 CL mode In v5.1, [ordered] is not a type, nor is OrderedDictionary included in CoreTypes. [ordered] @{} syntax is permitted in v5.1 ConstrainedLanguage mode, but use of the object is limited. --- .../Microsoft.PowerShell.Core/About/about_Language_Modes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md index fd60edff96aa..b57e3666337e 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -323,6 +323,10 @@ Special cases: - `[ref]` - Casting an object to type `[ref]` or `[Management.Automation.PSReference]` is not permitted. Other uses are permitted. +- `[ordered]` - The `[ordered] @{}` expression is permitted and creates an + object of type `[Collections.Specialized.OrderedDictionary]`. However, + accessing methods of the object or directly instantiating an + **OrderedDictionary** is not permitted. ### `NoLanguage` mode From 3b2cd05de9c7a51f3de0bea7e00a29bd1fddfc03 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:26:05 +0000 Subject: [PATCH 6/6] Remove invalid variable from v5.1's RL mode list --- .../5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md | 1 - 1 file changed, 1 deletion(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md index b57e3666337e..195a78423759 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Language_Modes.md @@ -181,7 +181,6 @@ additional variables: - `$PSScriptRoot` - `$PSEdition` -- `$EnabledExperimentalFeatures` - Any environment variable, like `$env:TEMP` Only the following comparison operators are permitted: