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

Open
jshigetomi wants to merge19 commits intoPowerShell:master
base:master
Choose a base branch
Loading
fromjshigetomi:PSModulePathFix

Conversation

@jshigetomi
Copy link
Collaborator

@jshigetomijshigetomi commentedNov 21, 2025
edited
Loading

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:

  • Introduced thePSContentPath experimental feature, including its registration and description inExperimentalFeature.cs.[1][2]
  • Added two new cmdlets,Get-PSContentPath andSet-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:

  • Implemented logic inPowerShellConfig to get and set thePSContentPath value, 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:

  • Updated module path resolution inModuleIntrinsics to use the new content path, falling back to legacy locations if not set, and to set thePSUserContentPath environment variable for downstream consumers.[1][2][3]

Platform and Utility Updates:

  • AddedDefaultPSContentDirectory to platform-specific code to define the new default content directory for both Windows and Unix.
  • Minor addition ofSystem.Text.Json using 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

RokeJulianLockhart reacted with thumbs up emoji
@jshigetomijshigetomi added the CL-ExperimentalIndicates that a PR should be marked as an Experimental Feature in the Change Log labelNov 21, 2025
Copy link
Contributor

CopilotAI left a 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 featurePSContentPath with 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 centralizedUtils.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
FileDescription
ExperimentalFeature.csAdds PSContentPath experimental feature definition
GetSetPSContentPathCommand.csNew cmdlets for getting and setting PSContentPath with validation
PSConfiguration.csAdds GetPSContentPath/SetPSContentPath methods and lazy migration logic
Utils.csAdds GetPSContentPath() helper method with fallback logic
CorePsPlatform.csAdds DefaultPSContentDirectory constant for the new default location
ModuleIntrinsics.csUpdates GetPersonalModulePath and SetModulePath to use new API
HostUtilities.csUpdates profile path logic to use GetPSContentPath
HelpUtils.csUpdates help search path to use GetPSContentPath
InitialSessionState.csRegisters new Get/Set-PSContentPath cmdlets

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

Copy link
Contributor

CopilotAI left a 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.

@iSazonov
Copy link
Collaborator

If user intention is to migrate content to new location I believe the new cmdlets should help them.
I'd like to get not only current content path but size tooGet-PSContentPath -MeasureSize.

@kilasuit
Copy link
Collaborator

kilasuit commentedNov 23, 2025
edited
Loading

@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.
@iSazonov re this
I'd like to get not only current content path but size too Get-PSContentPath -MeasureSize.
I don't disagree on having that ability too.

@jshigetomijshigetomi marked this pull request as draftNovember 23, 2025 04:23
@jshigetomi
Copy link
CollaboratorAuthor

@kilasuit - Thanks for calling me out on that. Definitely intended this as a draft.

@microsoft-github-policy-servicemicrosoft-github-policy-servicebot added the Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept labelNov 26, 2025
@microsoft-github-policy-servicemicrosoft-github-policy-servicebot removed the Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept labelDec 1, 2025
@microsoft-github-policy-servicemicrosoft-github-policy-servicebot added the Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept labelDec 9, 2025
@microsoft-github-policy-servicemicrosoft-github-policy-servicebot removed the Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept labelDec 12, 2025
@jshigetomi
Copy link
CollaboratorAuthor

@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.

@jshigetomijshigetomi marked this pull request as ready for reviewDecember 12, 2025 23:38
@jshigetomijshigetomi requested a review froma team as acode ownerDecember 12, 2025 23:38
@kilasuit
Copy link
Collaborator

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.

I think that makes sense, perhaps this can also be provided via a script published to the gallery?

@iSazonov
Copy link
Collaborator

@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.

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
Copy link
CollaboratorAuthor

@iSazonov@kilasuit
Great feedback! The migration process is worth discussing with the community.
I think there was a decision to not automate migration and leave that up to users.
However, we can provide a script/instructions on migration.

Current Migration Steps:

  1. Find your OneDrive content path: ($env:PSModulePath -split ';')[0] | Split-Path -Parent
  2. Enable the feature: Enable-ExperimentalFeature -Name PSContentPath
  3. Restart PowerShell
  4. (Optional) Set custom path: Set-PSContentPath -Path "Desired\Path"
  5. Copy content: Copy-Item -Path $oldPath -Destination (Get-PSContentPath) -Recurse

Question: Should Get-PSContentPath support a -Legacy parameter to return the old Documents/OneDrive path? This would eliminate the need for PSModulePath parsing.

@iSazonov
Copy link
Collaborator

If we try to automate migration, it will most likely be a breaking change, because we cannot know all the real scenarios.
Historically, MSFT's policy is to avoid such situations. It is great policy.
Automation also eliminates the possibility of having this innovation as an experimental feature, since disabling it will not revert the migration operations performed.

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.
Then installing a new OS system or updating pwsh on existing OS systems won't break anything. At least there is a low risk, which is always present when updating versions.
New modules (resources) will be installed using new paths. If this breaks something, users can either migrate their environment or just disable the new feature without extra steps (coping files back).

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.
At the third stage (v7.8?), the old paths can be excluded from the code altogether.

@kilasuit
Copy link
Collaborator

Question: Should Get-PSContentPath support a -Legacy parameter to return the old Documents/OneDrive path?

I think this makes sense too.

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.
At the third stage (v7.8?), the old paths can be excluded from the code altogether.

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
Copy link
Collaborator

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 powershell,config.json It would decrease the need for cmdlets. A community module could add functions to get-/set) if really needed.

@kilasuit
Copy link
Collaborator

@doctordns if added topowershell.config.json it would not negate or decrease the need for a cmdlet here as tbh most don't seem AFAIK to make use of that file, though happy to be wrong on that.
Also no this cannot be a community module, it needs to be a Microsoft one and if needed can be shipped seperately to the gallery and pulled in to the release via thisPSGalleryModules.csproj file

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

Reviewers

@iSazonoviSazonoviSazonov left review comments

Copilot code reviewCopilotCopilot left review comments

@adityapatwardhanadityapatwardhanAwaiting requested review from adityapatwardhanadityapatwardhan is a code owner

@daxian-dbwdaxian-dbwAwaiting requested review from daxian-dbwdaxian-dbw is a code owner

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

Assignees

No one assigned

Labels

CL-ExperimentalIndicates that a PR should be marked as an Experimental Feature in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jshigetomi@iSazonov@kilasuit@doctordns

[8]ページ先頭

©2009-2025 Movatter.jp