fix(terminal): allow shell integration in powershell audit mode - #328570
Open
RITHIK KUMARAN K (RITHIKKUMARAN) wants to merge 1 commit into
Open
fix(terminal): allow shell integration in powershell audit mode#328570RITHIK KUMARAN K (RITHIKKUMARAN) wants to merge 1 commit into
RITHIK KUMARAN K (RITHIKKUMARAN) wants to merge 1 commit into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
RITHIK KUMARAN K (RITHIKKUMARAN)
force-pushed
the
fix/pwsh-audit-mode
branch
from
August 2, 2026 17:55
5124542 to
4bd3448
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #283151
Description
This PR allows VS Code's Terminal Shell Integration to initialize correctly when PowerShell 7.4+ is operating in the new
ConstrainedLanguageAudit 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.LanguageModeasConstrainedLanguage. However, it functions with full, unrestricted semantics because it is only logging actions, not blocking them. TheshellIntegration.ps1script historically bailed out immediately if the language mode was notFullLanguage, incorrectly breaking terminal features (prompt tracking, command decorations) for these users.Proposed Changes:
shellIntegration.ps1to query[System.Management.Automation.Security.SystemPolicy]::GetSystemLockdownPolicy()when a restricted language mode is detected.Audit, we safely bypass the bailout and allow shell integration to initialize.try...catchwrapper to ensure this check safely fails open on older PowerShell versions that do not support this API.How to test
$ExecutionContext.SessionState.LanguageModereportsConstrainedLanguageand[System.Management.Automation.Security.SystemPolicy]::GetSystemLockdownPolicy()reportsAudit.pwshprofile.