- Notifications
You must be signed in to change notification settings - Fork100
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
base:master
Are you sure you want to change the base?
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
jshigetomi commentedNov 20, 2025
Added support for Linux and MacOS pathway as well |
| Azure Pipelines successfully started running 1 pipeline(s). |
alerickson commentedNov 20, 2025
Opened PR to run CI tests here:#1913 |
jshigetomi commentedNov 20, 2025
Decided to use pwsh runspaces instead of reflection to call the PSContentPath API. |
Uh oh!
There was an error while loading.Please reload this page.
alerickson commentedNov 21, 2025
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! |
alerickson commentedNov 21, 2025
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
alerickson commentedNov 21, 2025
@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 commentedDec 12, 2025
I added tests so that it skips some PSContentPath tests if it's not enabled. |
Uh oh!
There was an error while loading.Please reload this page.
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:
powershell.config.json).PSUserContentPathin 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.MyDocuments\PowerShellfolder for user content.Refactoring and path resolution:
GetPathsFromEnvVarAndScopeto use the newpsUserContentPathvariable instead of the legacy documents path, ensuring the correct directory is used based on feature detection.Utility 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
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.