Repository navigation
Document that the Windows PowerShell PSModulePath fixup applies only to direct child processes - #13248
Conversation
…to direct child processes
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
There was a problem hiding this comment.
Pull request overview
This PR updates the about_PSModulePath documentation to clarify that PowerShell 7’s PSModulePath “fixup” for Windows PowerShell only applies when Windows PowerShell is started as a direct child process, and documents practical workarounds for indirect launches via intermediate native processes.
Changes:
- Adds an explicit “direct child only” limitation note plus three workaround examples (PowerShell 7.4+
Start-Process -Environment,cmd.exeset PSModulePath=, Pythonsubprocessenv filtering) to the PowerShell 7.4–7.7about_PSModulePatharticles. - Adds a corresponding note to the Windows PowerShell 5.1 article explaining how it can inherit a PowerShell 7
PSModulePath, with a cross-link to the PowerShell 7 article. - Updates
ms.datein all touched files.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md | Documents the direct-child limitation and adds workaround examples for indirect Windows PowerShell launches. |
| reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md | Same documentation enhancement for the 7.5 versioned article. |
| reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md | Same documentation enhancement for the 7.6 versioned article. |
| reference/7.7/Microsoft.PowerShell.Core/About/about_PSModulePath.md | Same documentation enhancement for the 7.7 versioned article. |
| reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md | Adds a Windows PowerShell-side inheritance note and links to the PowerShell 7 article. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Learn Build status updates of commit 5aff402: ✅ Validation status: passed
For more details, please refer to the build report. |
|
@microsoft-github-policy-service agree |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 190453c: ✅ Validation status: passed
For more details, please refer to the build report. |
Sean Wheeler (sdwheeler)
left a comment
There was a problem hiding this comment.
Thanks for the update.
PR Summary
The "Starting Windows PowerShell from PowerShell 7" section of
about_PSModulePathdocuments that PowerShell 7 sanitizesPSModulePathwhen it starts Windows PowerShell, but not that this only covers processes
PowerShell 7 starts directly. When Windows PowerShell is started through
an intermediate process (
pwsh->cmd.exe, Python, or any other nativeprocess ->
powershell.exe), the intermediate inherits the unmodifiedPSModulePathof PowerShell 7 and passes it down. The PowerShell 7 modulepaths then precede the Windows PowerShell system module path, shared module
names such as
Microsoft.PowerShell.Utilityresolve to PowerShell 7 versionsthat Windows PowerShell can't load, and the cmdlets from those modules fail
with
CommandNotFoundException.The PowerShell Engine WG reviewed this behavior in
PowerShell/PowerShell#27774, concluded it is by design on both sides, and
invited this documentation enhancement to
about_PSModulePath.Changes:
reference/7.4|7.5|7.6|7.7/.../About/about_PSModulePath.md: document thedirect-children limitation at the end of "Starting Windows PowerShell from
PowerShell 7", with three verified workarounds (PowerShell 7.4+
Start-Process -Environment,cmd.exeset PSModulePath=, Pythonsubprocesswith the variable removed).reference/5.1/.../About/about_PSModulePath.md: add a note on theinheriting side under "Windows PowerShell startup", cross-linking the
PowerShell 7 article.
ms.datein the five touched files.Every behavior described was measured on Windows 11 (pwsh 7.6.4, Windows
PowerShell 5.1.26100.8972): direct child sanitized (6 entries -> 4), one
intermediate process of any kind sufficient to reproduce (6 entries kept,
CommandNotFoundException), each workaround verified. Details inPowerShell/PowerShell#27774.
PR Checklist