Skip to content

fix(terminal): allow shell integration in powershell audit mode - #328570

Open
RITHIK KUMARAN K (RITHIKKUMARAN) wants to merge 1 commit into
microsoft:mainfrom
RITHIKKUMARAN:fix/pwsh-audit-mode
Open

fix(terminal): allow shell integration in powershell audit mode#328570
RITHIK KUMARAN K (RITHIKKUMARAN) wants to merge 1 commit into
microsoft:mainfrom
RITHIKKUMARAN:fix/pwsh-audit-mode

Conversation

@RITHIKKUMARAN

Copy link
Copy Markdown

Fixes #283151

Description

This PR allows VS Code's Terminal Shell Integration to initialize correctly when PowerShell 7.4+ is operating in the new ConstrainedLanguage Audit mode.

Root Cause:
PowerShell 7.4 introduced a security audit mode. When a system (such as modern Windows 11 machines) has a Windows Defender Application Control (WDAC) audit-only policy active, PowerShell reports its $ExecutionContext.SessionState.LanguageMode as ConstrainedLanguage. However, it functions with full, unrestricted semantics because it is only logging actions, not blocking them. The shellIntegration.ps1 script historically bailed out immediately if the language mode was not FullLanguage, incorrectly breaking terminal features (prompt tracking, command decorations) for these users.

Proposed Changes:

  • Updated the language mode guard in shellIntegration.ps1 to query [System.Management.Automation.Security.SystemPolicy]::GetSystemLockdownPolicy() when a restricted language mode is detected.
  • If the lockdown policy explicitly returns Audit, we safely bypass the bailout and allow shell integration to initialize.
  • Included a try...catch wrapper to ensure this check safely fails open on older PowerShell versions that do not support this API.
  • Replicated the logic in the Copilot simulation test fixture to ensure consistency.

How to test

  1. On a Windows 11 machine, enable a WDAC / App Control audit-only policy.
  2. Launch PowerShell 7.4+. Verify that $ExecutionContext.SessionState.LanguageMode reports ConstrainedLanguage and [System.Management.Automation.Security.SystemPolicy]::GetSystemLockdownPolicy() reports Audit.
  3. Open the integrated terminal in VS Code using the pwsh profile.
  4. Verify that terminal shell integration (prompt tracking and command boundaries) successfully initializes instead of silently aborting.

Copilot AI review requested due to automatic review settings August 1, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminal/common/scripts/shellIntegration.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal Shell Integration requires update for newer PowerShell 7.4+ ConstrainedLanguage AUDIT mode

3 participants