Title: Unhandled Win32Exception during network-drive discovery interrupts FileSystem provider initialization in AppContainer · Issue #28268 · PowerShell/PowerShell · GitHub
Open Graph Title: Unhandled Win32Exception during network-drive discovery interrupts FileSystem provider initialization in AppContainer · Issue #28268 · PowerShell/PowerShell
X Title: Unhandled Win32Exception during network-drive discovery interrupts FileSystem provider initialization in AppContainer · Issue #28268 · PowerShell/PowerShell
Description: Summary On Windows, a failure to resolve a network drive's mapping inside an AppContainer-restricted process can abort FileSystemProvider.InitializeDefaultDrives(). In the observed environment, both WNetGetConnectionW and the subsequent ...
Open Graph Description: Summary On Windows, a failure to resolve a network drive's mapping inside an AppContainer-restricted process can abort FileSystemProvider.InitializeDefaultDrives(). In the observed environment, bot...
X Description: Summary On Windows, a failure to resolve a network drive's mapping inside an AppContainer-restricted process can abort FileSystemProvider.InitializeDefaultDrives(). In the observed environment,...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/28268
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unhandled Win32Exception during network-drive discovery interrupts FileSystem provider initialization in AppContainer","articleBody":"### Summary\n\nOn Windows, a failure to resolve a network drive's mapping inside an AppContainer-restricted process can abort `FileSystemProvider.InitializeDefaultDrives()`.\n\nIn the observed environment, both `WNetGetConnectionW` and the subsequent DOS-device fallback fail with `ERROR_ACCESS_DENIED (5)`. The fallback throws `Win32Exception`, which is not caught by the per-drive exception handling in `InitializeDefaultDrives()`.\n\nThis leaves provider initialization incomplete even though ordinary filesystem operations in the permitted workspace still succeed.\n\n### Environment\n\n- Windows 11 Pro for Workstations Insider Preview, x64, version 10.0.26220.\n- Official MSI-installed PowerShell 7.6.8 was the unmodified control.\n- Restricted execution: Codex Windows MXC sandbox with a workspace-write permission profile.\n- The same Windows user has existing mapped network drives. Private share names are omitted.\n- The launcher was a local build of Codex CLI 0.164.0 containing separate SystemRoot-environment and Windows SQL-migration line-ending fixes. This is not a claim that the launcher binary was an unmodified official release.\n- The PowerShell source used for the local comparison was tag `v7.6.8`, commit `6e29e4530c5631b6d3d2afacb49c6f1267fb0b42`.\n\n### Steps to reproduce\n\nPrerequisite: a Windows environment with an existing network drive visible to `DriveInfo.GetDrives()`, and a restricted process in which network-mapping/DOS-device queries return access denied. I have reproduced this using MXC; I have not independently reproduced it with a minimal standalone CreateAppContainerProfile launcher, or established that every AppContainer configuration is affected.\n\n1. Start the unmodified PowerShell executable outside the sandbox with `-NoLogo -NoProfile -NonInteractive`.\n2. Execute:\n\n ```powershell\n [Console]::WriteLine($PSVersionTable.PSVersion.ToString())\n [Console]::WriteLine([bool](Get-PSDrive -Name Temp -ErrorAction SilentlyContinue))\n [IO.DriveInfo]::GetDrives() | Select-Object Name, DriveType\n Get-PSDrive -PSProvider FileSystem | Select-Object Name, Root, DisplayRoot\n ```\n\n3. Run the same executable and commands through the MXC workspace sandbox. The launcher invocation used in the investigation has this form:\n\n ```powershell\n & codex -c 'windows.sandbox=\"mxc\"' -c 'features.prefer_mxc=true' sandbox --permission-profile ':workspace' -C $independentTestDirectory -- 'C:\\Program Files\\PowerShell\\7\\pwsh.exe' -NoLogo -NoProfile -NonInteractive -File $probeScript\n ```\n\n Both variables above designate an independent local diagnostic directory/script. No profile, registry execution-policy bypass, drive remapping, service change, or ACL adjustment is required for these comparisons.\n\n4. Compare provider startup and the Temp drive. To investigate the underlying failure, capture managed first-chance exceptions while creating another runspace and triggering its FileSystem provider.\n\n### Actual behavior and captured exception\n\nThe sandboxed control prints the FileSystem provider initialization warning. Its initial `$Error` collection is empty, so inspecting `$Error` after startup did not recover the original exception. The command can still exit 0 and perform permitted local writes.\n\nA process-local `AppDomain.CurrentDomain.FirstChanceException` handler, used while opening/using a separate runspace, captured this exception chain. Localized message text is omitted:\n\n```text\nSystem.Management.Automation.ProviderInvocationException\n ---> System.Management.Automation.ProviderInvocationException\n ---> System.ComponentModel.Win32Exception (5)\n at Interop.Windows.GetDosDeviceForNetworkPath(Char deviceName)\n at Microsoft.PowerShell.Commands.FileSystemProvider.WinGetSubstitutedPathForNetworkDosDevice(String driveName)\n at Microsoft.PowerShell.Commands.FileSystemProvider.GetRootPathForNetworkDriveOrDosDevice(DriveInfo driveInfo)\n at Microsoft.PowerShell.Commands.FileSystemProvider.InitializeDefaultDrives()\n at System.Management.Automation.SessionStateInternal.InitializeProvider(...)\n```\n\nIndependent native API probes and direct reflection calls to the installed provider method gave:\n\n| Probe | Normal process | MXC process |\n| --- | --- | --- |\n| WNetGetConnectionW for each of two mapped drives | Success, correct UNC mapping | Error 5 |\n| QueryDosDeviceW for those drive letters | Success | Error 5 |\n| GetRootPathForNetworkDriveOrDosDevice for those drives | Correct UNC mapping | Win32Exception (5) |\n| Temp PSDrive after startup | Present | Absent |\n\nThe API error results were measured directly, rather than inferred only from the warning.\n\n### Expected behavior\n\nFailure to obtain optional network-drive mapping/display information should not prevent the provider from finishing initialization of other drives, including Temp.\n\nA possible behavior is to retain the drive-letter root with an unavailable DisplayRoot and continue initialization. This does not require granting additional permissions to the restricted process or making inaccessible filesystem paths accessible.\n\nThe underlying reason MXC denies these queries has not been established here. This report concerns PowerShell's handling of that failure.\n\n### Source inspection and local comparison\n\nIn [FileSystemProvider.cs at the tested commit](https://github.com/PowerShell/PowerShell/blob/6e29e4530c5631b6d3d2afacb49c6f1267fb0b42/src/System.Management.Automation/namespaces/FileSystemProvider.cs):\n\n- `GetRootPathForNetworkDriveOrDosDevice()` catches failure of the initial network-mapping lookup and can attempt the DOS-device fallback.\n- The per-drive handling in `InitializeDefaultDrives()` catches `IOException`, `SecurityException`, and `UnauthorizedAccessException`, but not `Win32Exception`.\n\nI built a local comparison that handles `Win32Exception` around this network lookup and retains a null DisplayRoot. This was tested with the same sandbox policy:\n\n| PowerShell build/context | Initialization warning | Temp drive | Probe script and permitted file write |\n| --- | --- | --- | --- |\n| Official 7.6.8, normal process | No | Present | Pass |\n| Official 7.6.8, MXC | Yes | Absent | Pass |\n| Local comparison, normal process | No | Present | Pass |\n| Local comparison, MXC | No | Present | Pass |\n\nFresh process tests after local installation also passed. Sandbox boundary checks continued to reject writes outside the permitted workspace. No configuration, service, or lasting ACL change was used to obtain these results.\n\nThis comparison supports handling the mapping exception gracefully; it does not establish that all network-drive initialization failures have the same cause.\n\n### Related reports\n\n- #7212, especially [this comment](https://github.com/PowerShell/PowerShell/issues/7212#issuecomment-501336453), describes the same network-drive discovery function failing in a Windows container. That issue was later [closed for inactivity](https://github.com/PowerShell/PowerShell/issues/7212#issuecomment-1824436557), which does not establish that this current case was fixed.\n- #27253 concerns a different AppContainer failure involving fixed-drive root existence checks; I am not claiming it is the same defect.\n- [openai/codex#55004](https://github.com/openai/codex/issues/55004) reports the startup warning and empty error collection, but does not contain this captured inner exception chain.\n\nPlease consider making FileSystem provider initialization resilient to this network-mapping Win32Exception, and adding coverage for failed mapping queries in a restricted Windows context.\n\nNo private share names, user/project paths, credentials, transfer URLs, or raw session logs are included.\n\n","author":{"url":"https://github.com/mcc1","@type":"Person","name":"mcc1"},"datePublished":"2026-10-26T20:01:20Z","url":"https://github.com/PowerShell/PowerShell/issues/28268"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bdef9ce8-63a7-53d8-ce68-c2fdac87f43e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AB5C:39985A:1CC72D:25EE80:6AFD0138 |
| html-safe-nonce | 5bb1626901643efaf806b114a53543fa35e90a96fae27566a168d4aa679b27c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjVDOjM5OTg1QToxQ0M3MkQ6MjVFRTgwOjZBRkQwMTM4IiwidmlzaXRvcl9pZCI6IjIyMjc3MDAyNzI5NDYwMjA2NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9085fde4cdf46a6fa844124b4f7a82bdd795c0cbd8e6f53e92466c6ab743bf38 |
| hovercard-subject-tag | issue:6047190418 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/28268/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f66349712fb55ffc093246e0eb582eb1daaa8483a7487a136834f4fb5347ac4/PowerShell/PowerShell/issues/28268 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f66349712fb55ffc093246e0eb582eb1daaa8483a7487a136834f4fb5347ac4/PowerShell/PowerShell/issues/28268 |
| og:image:alt | Summary On Windows, a failure to resolve a network drive's mapping inside an AppContainer-restricted process can abort FileSystemProvider.InitializeDefaultDrives(). In the observed environment, bot... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mcc1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cfabad6ee26d2b84c7afef4ae0cc71b8b692fb9d66f9f15997652ef991bfd3f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 35f85b78676038389558a41adf8d76e474592ede |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width