Skip to content

ConstrainedLanguage mode includes the [ScriptBlock] type #13337

Open

Description

@iRon7

Type of issue

Missing information

Feedback

In comparison to the RestrictedLanguage mode where "users can run commands, but can't use scriptblocks",
ConstrainedLanguage mode does support the [ScriptBlock] type:

$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
$ScriptBlock = { 1 + 2 } # Or even explicit: [ScriptBlock]{ 1 + 2 }
Invoke-Command $ScriptBlock # returns: 3

But the [ScriptBlock] type isn't listed under "The following .NET types are permitted in ConstrainedLanguage mode." in the ConstrainedLanguage mode section (even it does contain types along with [ValidateScript] that actually require a scriptblock for the constructor)

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.6

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.6/Microsoft.PowerShell.Core/About/about_Language_Modes.md

Author

Sean Wheeler (@sdwheeler)

Platform Id

6eaa1444-a7c0-932d-a3bb-4f164f27b6c9

Document Id

057b2c45-ec3f-fbe6-f1f9-1962f72bc112

Activity

  1. added
    needs-triage
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions