- Notifications
You must be signed in to change notification settings - Fork8.1k
Add Experimental Feature PSContentPath#26509
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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ether or not migration took place
…ault PSContentPath location
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.
Pull request overview
This PR introduces an experimental feature calledPSContentPath that changes the default location for PowerShell user content (modules, scripts, help, and profiles) fromDocuments\PowerShell toLocalAppData\PowerShell on Windows, and provides a configurable path viaGet-PSContentPath andSet-PSContentPath cmdlets. The feature includes lazy migration logic to move config files from the old location to the new location when the experimental feature is enabled.
Key changes:
- Adds experimental feature
PSContentPathwith new cmdlets to get/set the content path - Implements lazy migration from old config directory to new default location (LocalAppData)
- Updates all content path references to use the centralized
Utils.GetPSContentPath()API
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| ExperimentalFeature.cs | Adds PSContentPath experimental feature definition |
| GetSetPSContentPathCommand.cs | New cmdlets for getting and setting PSContentPath with validation |
| PSConfiguration.cs | Adds GetPSContentPath/SetPSContentPath methods and lazy migration logic |
| Utils.cs | Adds GetPSContentPath() helper method with fallback logic |
| CorePsPlatform.cs | Adds DefaultPSContentDirectory constant for the new default location |
| ModuleIntrinsics.cs | Updates GetPersonalModulePath and SetModulePath to use new API |
| HostUtilities.cs | Updates profile path logic to use GetPSContentPath |
| HelpUtils.cs | Updates help search path to use GetPSContentPath |
| InitialSessionState.cs | Registers new Get/Set-PSContentPath cmdlets |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
src/System.Management.Automation/engine/Configuration/GetSetPSContentPathCommand.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/System.Management.Automation/engine/Configuration/GetSetPSContentPathCommand.cs OutdatedShow resolvedHide resolved
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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
src/System.Management.Automation/engine/Configuration/GetSetPSContentPathCommand.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
iSazonov commentedNov 22, 2025
If user intention is to migrate content to new location I believe the new cmdlets should help them. |
kilasuit commentedNov 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@jshigetomi - Please mark this PR as a Draft & go through the PR checklist & mark things appropriately add some PR Context as isrequested in the PR template. Until all thats done we shouldn't look to accept this pr. You can do better than this & should do so in future too. |
jshigetomi commentedNov 23, 2025
@kilasuit - Thanks for calling me out on that. Definitely intended this as a draft. |
jshigetomi commentedDec 12, 2025
@iSazonov Get-PSContentPath is only available when the PSContentPath experimental feature is enabled. When enabled, the content path defaults to LocalAppData rather than the OneDrive-synced Documents folder. This means -MeasureSize would only be useful if a user explicitly sets their content path back to the OneDrive location, which defeats the purpose of the feature. Should we consider making Get-PSContentPath available outside the experimental feature gate? That way users could measure their current Documents\PowerShell directory size even without enabling the feature. |
kilasuit commentedDec 13, 2025
I think that makes sense, perhaps this can also be provided via a script published to the gallery? |
iSazonov commentedDec 13, 2025
I would make this question more generalized. What will migration look like? And do we want to automate it somehow? Can you describe the migration process? How will users be forced to act after installing a new version with support for this feature? |
jshigetomi commentedDec 13, 2025
@iSazonov@kilasuit Current Migration Steps:
Question: Should Get-PSContentPath support a -Legacy parameter to return the old Documents/OneDrive path? This would eliminate the need for PSModulePath parsing. |
iSazonov commentedDec 14, 2025
If we try to automate migration, it will most likely be a breaking change, because we cannot know all the real scenarios. To avoid these problems, I see one way - to put the new paths in the first place and keep the old ones in the second. Gradually, all the resources will end up in new folders. Then, at the second stage (v7.7?), we will be able to disable the old paths by default, but users will be able to turn them back on explicitly. |
kilasuit commentedDec 16, 2025
I think this makes sense too.
I think the plan would be that this is all contained within 7.6.x as not to drag this out for more years but that's something that@jshigetomi & team can confirm on, but that was my expectation at least |
doctordns commentedDec 16, 2025
It's probably too late, but I wondered if setting the content path for a given PWSH session could not be set in JSON such as |
kilasuit commentedDec 17, 2025
@doctordns if added to |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
This pull request introduces a new experimental feature,
PSContentPath, which allows users to customize the default location for PowerShell content (such as modules, scripts, help, and profiles). It adds new cmdlets for getting and setting this path, updates module path logic to respect the new setting, and implements a migration mechanism for user configuration files. The most important changes are as follows:New Experimental Feature and Cmdlets:
PSContentPathexperimental feature, including its registration and description inExperimentalFeature.cs.[1][2]Get-PSContentPathandSet-PSContentPath, to allow users to retrieve and configure the PowerShell content path. These cmdlets are registered as core cmdlets and include path validation and error handling.[1][2][3]Configuration and Migration Logic:
PowerShellConfigto get and set thePSContentPathvalue, including a migration mechanism that moves the per-user configuration file to the new location if the experimental feature is enabled. Migration is performed lazily and only once, with fallback handling to avoid breaking PowerShell if migration fails.[1][2][3][4]Module Path Resolution Updates:
ModuleIntrinsicsto use the new content path, falling back to legacy locations if not set, and to set thePSUserContentPathenvironment variable for downstream consumers.[1][2][3]Platform and Utility Updates:
DefaultPSContentDirectoryto platform-specific code to define the new default content directory for both Windows and Unix.System.Text.Jsonusing directive for future extensibility.These changes lay the groundwork for more flexible and user-configurable PowerShell content storage, improving support for scenarios like roaming profiles, containerization, and read-only file systems.
PR Context
This change represents a major milestone for the PowerShell ecosystem—one that has been long requested by the community, discussed extensively, and is finally becoming a reality. The feature originated from community feedback in#15552, aligns with related work inPowerShell/PSResourceGet#1912, and was shaped through detailed specifications inPowerShell/PowerShell-RFC#388.
This feature lays the foundation for flexible, user-configurable PowerShell content storage, addressing scenarios such as roaming profiles and containerized environments.
By enabling customization of content paths, we empower users to adapt PowerShell to modern deployment and security requirements.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header