Skip to content

[release/v7.6.2] Enable usage in AppContainers#27423

Merged
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/27266-2475feb87
May 13, 2026
Merged

[release/v7.6.2] Enable usage in AppContainers#27423
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/27266-2475feb87

Conversation

@daxian-dbw
Copy link
Copy Markdown
Member

Backport of #27266 to release/v7.6.2

Triggered by @daxian-dbw on behalf of @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)

Customer Impact

  • Customer reported
  • Found internally

Fixes issue #27253 where PowerShell fails to initialize in AppContainer environments. By default, AppContainers block access to the root of the system drive. PowerShell was incorrectly treating "access denied" as the drive not existing, causing initialization failures and preventing modules from loading.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Validated by the original PR. Testing can only be done interactively in an AppContainer environment. The fix treats "access denied" on the root of the system drive as evidence the drive exists, rather than treating it as absent.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Small targeted fix that changes how PowerShell treats "access denied" errors when checking drive accessibility in AppContainer environments. The change is additive — it only affects AppContainer scenarios where the root of the system drive is blocked.

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Copilot AI review requested due to automatic review settings May 13, 2026 19:13
@daxian-dbw daxian-dbw added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports the AppContainer initialization fix to release/v7.6.2 by avoiding false “drive doesn’t exist” conclusions when access to the system-drive root is denied, allowing filesystem PSDrives (and therefore module autoloading/cmdlet discovery) to work in AppContainer environments.

Changes:

  • Replaces fixed-drive root existence checks with a new helper that treats UnauthorizedAccessException as evidence the path exists.
  • Uses Environment.SpecialFolderOption.DoNotVerify when resolving the user’s MyDocuments path on Windows to avoid verification failures in restricted environments.

Reviewed changes

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

File Description
src/System.Management.Automation/namespaces/FileSystemProvider.cs Adds SafeDoesPathExist and uses it for fixed-drive/root validation to support AppContainer-restricted volume roots.
src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Resolves MyDocuments with DoNotVerify on Windows to avoid access/verification issues in constrained contexts.

Comment on lines +1247 to +1250
catch
{
return false;
}
@daxian-dbw daxian-dbw merged commit 8afbd5f into PowerShell:release/v7.6.2 May 13, 2026
40 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6.2/27266-2475feb87 branch May 13, 2026 22:03
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