Skip to content

[release/v7.6.6] Add support for new WLDP setting EnableFileOnlyEntry - #27922

Merged
Patrick Meinecke (SeeminglyScience) merged 1 commit into
PowerShell:release/v7.6.6from
SeeminglyScience:backport/release/v7.6.6/26752-2ca393d6b
Sep 1, 2026
Merged

[release/v7.6.6] Add support for new WLDP setting EnableFileOnlyEntry#27922
Patrick Meinecke (SeeminglyScience) merged 1 commit into
PowerShell:release/v7.6.6from
SeeminglyScience:backport/release/v7.6.6/26752-2ca393d6b

Conversation

@SeeminglyScience

Copy link
Copy Markdown
Contributor

Backport of #26752 to release/v7.6.6

Triggered by Patrick Meinecke (@SeeminglyScience) on behalf of Patrick Meinecke (@SeeminglyScience)

Original CL Label: CL-Engine

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Adds support for a new WLDP (Windows Lockdown Policy) setting enabling FileOnlyEntry restriction, for use in managed/locked-down deployments.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Cherry-picked cleanly with no conflicts. Original PR validated with a companion policy manifest change; this is a prerequisite for the FileOnlyEntry crash fix (PR #27880) also queued for backport.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Adds a new opt-in WLDP setting check that only affects behavior when the setting is explicitly enabled in a managed environment; default behavior is unchanged. Windows-specific security-adjacent code path, but additive and gated behind the new setting.

Copilot AI lite review requested due to automatic review settings September 1, 2026 01:19
@SeeminglyScience Patrick Meinecke (SeeminglyScience) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Sep 1, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Pull request overview

Backport to release/v7.6.6 that adds support for a new WLDP setting (EnableFileOnlyEntry / “FileOnlyEntry”) to enforce that PowerShell only starts when -File is provided, and blocks interactive/non-file entry points such as -Command, -EncodedCommand, -NoExit, and server modes when the policy is enabled.

Changes:

  • Add native WLDP query support for a boolean application setting (“FileOnlyEntry”) with an environment-variable fallback for testing.
  • Enforce FileOnlyEntry restrictions in the console host command-line parser (and an extra guard for server mode startup).
  • Add Windows admin-only Pester coverage plus a test helper switch to toggle the setting via machine environment variables.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/tools/Modules/HelpersSecurity/HelpersSecurity.psm1 Extends the test support cmdlet to set/revert the FileOnlyEntry debug env var.
test/powershell/Modules/Microsoft.PowerShell.Security/FileOnlyEntry.Tests.ps1 Adds Pester coverage validating blocked entry modes and expected policy error messages.
src/System.Management.Automation/security/wldpNativeMethods.cs Introduces a WLDP boolean setting query and caches the FileOnlyEntry enabled state.
src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx Adds localized strings for FileOnlyEntry policy enforcement errors.
src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Adds a server-mode guard when FileOnlyEntry is enabled; minor control-flow refactor to return exit codes directly.
src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Enforces FileOnlyEntry policy across relevant CLI switches and missing--File scenarios.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +98 to +115
private static bool TestBooleanWldpSetting(string settingName)
{
int hr = WldpNativeMethods.WldpGetApplicationSettingBoolean(
AppManifestId,
settingName,
out bool result);

PSEtwLog.LogWDACQueryEvent(
"WldpGetApplicationSettingBoolean",
settingName,
hr,
result ? 1 : 0);

if (hr is not 0)
{
result = false;
}

@SeeminglyScience
Patrick Meinecke (SeeminglyScience) merged commit 12c3b77 into PowerShell:release/v7.6.6 Sep 1, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants