Skip to content
System hardening
ASD ISMISM-1622

ASD ISM 1622 Ensure PowerShell uses Constrained Language Mode

What it says

PowerShell is configured to use Constrained Language Mode.

Quoted as published. Everything else on this page is written by Control Stack.

In plain English

Configure PowerShell on workstations and servers to use Constrained Language Mode, which keeps cmdlets working but limits scripts' access to .NET, COM and Windows APIs.

PowerShell must be configured to use Constrained Language Mode on workstations and servers, in each version installed. A language mode sets which parts of the PowerShell language a session can use. This one keeps cmdlets (PowerShell's built-in commands) and basic scripting available, but permits only a short list of object types, which cuts off most access to .NET, COM and Windows APIs. Switching the mode inside a session is only an experiment, not a configuration. Who may run PowerShell at all is a separate matter (ISM-1491).

Why it matters

Full language mode lets a script call .NET, COM and Windows APIs directly, and malicious actors abuse that to go well beyond what cmdlets allow. Constrained Language Mode removes most of that reach while leaving PowerShell usable for routine administration.

How to implement

  1. Find the scripts that will break before enforcing anything.

    In a test session, set the language mode to ConstrainedLanguage and run each administrative and product script, listing what fails. From PowerShell 7.4, PowerShell also logs what would be restricted, in its PowerShellCore/Analytic log (off by default), while a policy of the type that step 3 recommends is in audit mode.

  2. Trust only the scripts that genuinely need full language.

    Scripts the policy allows run in full language mode, while interactive sessions and everything else stay constrained. Rewrite what you can to use cmdlets, then sign or allow only reviewed scripts (ISM-1657 limits scripts to an approved set). Path rules must not trust folders unapproved users can write to (ISM-1392).

  3. Set the mode through an enforcing application control policy.

    ISM-0843, ISM-1490 and ISM-1656 already require application control on workstations and servers, but PowerShell moves to Constrained Language Mode by itself only when Windows' own application control enforces script rules. Choose a type that puts Windows into System Lockdown mode, which Microsoft says is needed so the mode cannot be bypassed.

  4. Handle products and devices that cannot run constrained.

    Ask the vendor for signed scripts your policy can trust. PowerShell 7 on Linux or macOS does not detect these policies, so remove it there unless you can show it runs constrained. Otherwise record a risk for the authorising officer, as a known shortfall until fixed.

Keep it running

Test new administrative scripts and product updates under the mode before release, and trust only those that need full language. A new PowerShell version, a change to the application control policy or a new script-based product should trigger a recheck.

Evidence and audit

  1. Check 1 of 3What an auditor asks for

    Ask for

    A live reading of $ExecutionContext.SessionState.LanguageMode in each installed PowerShell version, on a sample of workstations and servers drawn from the IT equipment registers (ISM-0336, ISM-1869) and a discovery scan.

    Look at

    The value returned in an interactive session under each kind of account allowed to run PowerShell, for powershell.exe and pwsh.exe where installed.

    Good evidence

    Every sampled device returns ConstrainedLanguage in each installed version, under every kind of account tested, including privileged accounts used for routine administration.

  2. Check 2 of 3What an auditor asks for

    Ask for

    A test on the same devices that tries to get out of the mode: setting the language mode to FullLanguage, using Add-Type with inline C# code, creating a COM object such as WScript.Shell and running powershell.exe -Version 2.

    Look at

    Which version the -Version 2 attempt starts, and whether the language mode change, Add-Type and COM attempts are refused, because a policy only in audit mode can report the mode without enforcing it.

    Good evidence

    The language mode change, Add-Type and COM attempts are refused, the session still reports ConstrainedLanguage afterwards, and the -Version 2 attempt fails or starts a later version in ConstrainedLanguage (ISM-1621).

  3. Check 3 of 3What an auditor asks for

    Ask for

    The application control policy as applied on those devices, with the scripts and locations it trusts.

    Look at

    Whether it is in enforcing rather than audit mode, which scripts it trusts, and whether unapproved users can write to any trusted location.

    Good evidence

    The policy is enforcing on each sampled device, trusted scripts are limited to the organisation-approved set (ISM-1657), and unapproved users cannot write to any trusted location (ISM-1392).

Mappings

Closest match in ASD Essential Eight: E8-AH-ML3.3, PowerShell is configured to use Constrained Language Mode, which asks for the same thing.

ISO 27001

ISO/IEC 27001: 2 mappings

  • A.8.9Configuration managementPartially meets
Essential Eight

ASD Essential Eight: 3 mappings

Mappings show how controls relate across frameworks. They do not imply full equivalence or certification.