Skip to content

Document that the Windows PowerShell PSModulePath fixup applies only to direct child processes - #13248

Merged
Sean Wheeler (sdwheeler) merged 2 commits into
MicrosoftDocs:mainfrom
Sylvain13bdr:docs-psmodulepath-grandchild
Aug 25, 2026
Merged

Sean Wheeler (sdwheeler) merged 2 commits into
MicrosoftDocs:mainfrom
Sylvain13bdr:docs-psmodulepath-grandchild

Conversation

@Sylvain13bdr

Copy link
Copy Markdown
Contributor

PR Summary

The "Starting Windows PowerShell from PowerShell 7" section of
about_PSModulePath documents that PowerShell 7 sanitizes PSModulePath
when 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 native
process -> powershell.exe), the intermediate inherits the unmodified
PSModulePath of PowerShell 7 and passes it down. The PowerShell 7 module
paths then precede the Windows PowerShell system module path, shared module
names such as Microsoft.PowerShell.Utility resolve to PowerShell 7 versions
that 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 the
    direct-children limitation at the end of "Starting Windows PowerShell from
    PowerShell 7", with three verified workarounds (PowerShell 7.4+
    Start-Process -Environment, cmd.exe set PSModulePath=, Python
    subprocess with the variable removed).
  • reference/5.1/.../About/about_PSModulePath.md: add a note on the
    inheriting side under "Windows PowerShell startup", cross-linking the
    PowerShell 7 article.
  • Update ms.date in 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 in
PowerShell/PowerShell#27774.

PR Checklist

  • Descriptive Title: This PR's title is a synopsis of the changes it proposes.
  • Summary: This PR's summary describes the scope and intent of the change.
  • Contributor's Guide: I have read the contributor's guide.
  • Style: This PR adheres to the style guide.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

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

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.exe set PSModulePath=, Python subprocess env filtering) to the PowerShell 7.4–7.7 about_PSModulePath articles.
  • 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.date in 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.

Comment thread reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md
Comment thread reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md
Comment thread reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md
Comment thread reference/7.7/Microsoft.PowerShell.Core/About/about_PSModulePath.md
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 5aff402:

✅ Validation status: passed

File Status Preview URL Details
reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-5.1)
reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.4)
reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.5)
reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.6)
reference/7.7/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.7)

For more details, please refer to the build report.

@Sylvain13bdr

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 190453c:

✅ Validation status: passed

File Status Preview URL Details
reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-5.1)
reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.4)
reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.5)
reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.6)
reference/7.7/Microsoft.PowerShell.Core/About/about_PSModulePath.md ✅Succeeded View (powershell-7.7)

For more details, please refer to the build report.

@sdwheeler Sean Wheeler (sdwheeler) 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.

Thanks for the update.

@sdwheeler
Sean Wheeler (sdwheeler) merged commit f435f86 into MicrosoftDocs:main Aug 25, 2026
5 checks passed
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.

3 participants