Skip to content

Fail clearly when loaded in Constrained Language Mode - #7

Merged
HalRiveria merged 2 commits into
mainfrom
feat/clm-check
Oct 28, 2026
Merged

HalRiveria merged 2 commits into
mainfrom
feat/clm-check

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong. On a machine locked to Constrained Language Mode (AppLocker or WDAC policy), dot-sourcing the kit failed with Cannot convert value to type "System.Management.Automation.PSTypeName". Only core types are supported in this language mode. That doesn't tell you the kit can't run there, or why.

What changed. Before any Add-Type, the kit checks $ExecutionContext.SessionState.LanguageMode and, if it isn't FullLanguage, throws a message naming the mode, saying the kit needs FullLanguage to compile its C#, and what usually sets it. README "Limits" gets a line on this, plus a sentence on endpoint security products that flag runtime Add-Type.

Testing. New harness assertion: a fresh process switched to ConstrainedLanguage dot-sources the kit and must get the new message. It fails against main's kit (raw PSTypeName error) and passes here; 180 assertions pass.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits October 28, 2026 03:16
On a machine locked to Constrained Language Mode, dot-sourcing the kit
failed with "Cannot convert value to type PSTypeName. Only core types
are supported in this language mode", which doesn't say what to do.
It now checks the language mode first and throws a message naming the
mode, why the kit needs FullLanguage, and what usually sets it. The
README's Limits section says so, and mentions endpoint security
flagging runtime Add-Type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wershell.exe

$PSHOME\powershell.exe doesn't exist under PowerShell 7. Uses the same
$selfExe as the PowerShell 7 CI change, so the two merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit f717cd5 into main Oct 28, 2026
1 check passed
@HalRiveria
HalRiveria deleted the feat/clm-check branch October 28, 2026 07:47
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.

2 participants