Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add PSContentPath Standard Platform Paths#1912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jshigetomi wants to merge7 commits intoPowerShell:master
base:master
Choose a base branch
Loading
fromjshigetomi:PSContentPath

Conversation

@jshigetomi
Copy link
Contributor

@jshigetomijshigetomi commentedNov 19, 2025
edited
Loading

PR Summary

This pull request introduces support for the PowerShell "PSContentPath" experimental feature, allowing users to customize the location of user content (such as modules and scripts) via an environment variable or configuration file. The code now prefers these new paths when the feature is enabled, improving flexibility and future compatibility.

Support for PSContentPath experimental feature:

  • Added logic to detect if the "PSContentPath" experimental feature is enabled by checking the PowerShell configuration file (powershell.config.json).
  • When enabled, the code looks for a customPSUserContentPath in the environment variable or configuration file, using it as the base path for user content if it exists. If not set, it defaults toLocalApplicationData\PowerShell.
  • If the experimental feature is not enabled, the code continues to use the legacyMyDocuments\PowerShell folder for user content.

Refactoring and path resolution:

  • UpdatedGetPathsFromEnvVarAndScope to use the newpsUserContentPath variable instead of the legacy documents path, ensuring the correct directory is used based on feature detection.

Utility methods:

  • Introduced two new helper methods:IsExperimentalFeatureEnabled (to check for enabled features in the config) andGetPSUserContentPath (to retrieve the custom user content path from environment or config).

PR Context

This change introduces support for the PowerShell PSContentPath experimental feature, enabling users to customize where PowerShell stores user content (modules, scripts, etc.). Historically, PowerShell has relied on fixed paths such as MyDocuments\PowerShell, which limits flexibility in modern environments. With this update, users can define a custom content path via an environment variable or configuration file, allowing PowerShell to adapt to diverse deployment and security scenarios.

The feature is a direct response to long-standing community feedback (seePowerShell/PowerShell#15552) and aligns with related work in#1912. It was shaped through detailed specifications inPowerShell/PowerShell-RFC#388. This milestone lays the foundation for flexible, user-configurable content storage, addressing needs such as:

Roaming profiles
Containerized environments
Read-only file systems

By introducing this capability, we empower users to tailor PowerShell to modern deployment and compliance requirements.

PR Checklist

RokeJulianLockhart reacted with thumbs up emoji
@jshigetomi
Copy link
ContributorAuthor

Added support for Linux and MacOS pathway as well

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alerickson
Copy link
Member

Opened PR to run CI tests here:#1913

@jshigetomi
Copy link
ContributorAuthor

Decided to use pwsh runspaces instead of reflection to call the PSContentPath API.
Talked to@TravisEz13 and found out that APIScan will require proof that APIs are public and not internal. So utilizing the new cmdlet Get-PSContentPath in a pwsh runspace to get the path from the config or default LOCALAppData location.

alerickson reacted with thumbs up emoji

@alerickson
Copy link
Member

Tests are looking good, currently 3 failing tests related to Lucene index issues (ie these are flakey tests due to a server side issue with the Gallery). In terms of this PR all tests are passing!

jshigetomi reacted with hooray emoji

@alerickson
Copy link
Member

All tests are passing now, PR looks good to me, just have one comment regarding whether to use default runspace created by the .Create() method or use current runspace.

if(psVersionObj!=null)psVersion=newVersion((int)psVersionObj.Major,(int)psVersionObj.Minor);
}
catch{
// Fallback if dynamic access fails
Copy link
Member

Choose a reason for hiding this comment

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

do we need to write a verbose message or warning?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

If $PSVersionTable doesn't work, what could the user do differently after knowing that this is where it breaks?
I'm not sure there is much they can do, but could be helpful knowing where it went wrong.
I will add a warning for now.

Copy link
Member

Choose a reason for hiding this comment

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

Could we add a debug message here, for dev debugging purposes?

@alerickson
Copy link
Member

@jshigetomi we reviewed your PR,@anamnavi has a couple comments/suggestions. Everything looks good otherwise. Because we can't test these changes until 7.7 is released we're going to hold off on merging until then.

@jshigetomi
Copy link
ContributorAuthor

I added tests so that it skips some PSContentPath tests if it's not enabled.
I check for it with test hooks and the availability of Get-PSContentPath.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@adityapatwardhanadityapatwardhanadityapatwardhan left review comments

@alericksonalericksonalerickson left review comments

@anamnavianamnavianamnavi left review comments

@SydneyhSmithSydneyhSmithAwaiting requested review from SydneyhSmithSydneyhSmith is a code owner

@shammu1shammu1Awaiting requested review from shammu1shammu1 is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jshigetomi@alerickson@adityapatwardhan@anamnavi

[8]ページ先頭

©2009-2025 Movatter.jp