-
Notifications
You must be signed in to change notification settings - Fork 129
Move PS content out of OneDrive #388
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 our terms of service and privacy 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?
Changes from all commits
828a981
9901f90
e9808dc
60ee0ab
95798e0
f35150d
e29eb58
239989a
310b1c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
RFC: RFC0066 | ||
Author: Justin Chung | ||
Status: Draft | ||
SupercededBy: N/A | ||
Version: 1.0 | ||
Area: Core | ||
Comments Due: 07/31/2025 | ||
Plan to implement: Yes | ||
--- | ||
|
||
# PowerShell User Content Location | ||
|
||
This RFC proposes moving the current PowerShell user content location out of OneDrive to the | ||
`LocalAppData` directory on Windows machines. | ||
|
||
## Motivation | ||
|
||
``` | ||
As a user, | ||
I can customize the location where PowerShell user content is installed, | ||
so that I can avoid problems created by file sync solutions like OneDrive. | ||
``` | ||
|
||
- PowerShell currently places profile, modules, and configuration files in the user's Documents | ||
folder, which is against established conventions for shell configurations and tools. | ||
- PowerShell content files in OneDrive can lead to unwanted syncing of module files, leading to | ||
various issues. | ||
- There is strong community demand for changing this behavior as the current setup is problematic | ||
for many users. | ||
- Changing the default location would align PowerShell with other developer tools and improve | ||
usability. | ||
|
||
## Specification | ||
|
||
- This will be an experimental feature. | ||
- The content folder location change will only apply to PowerShell on Windows. | ||
- Configurability of the content folder will apply to all platforms. | ||
- A configuration file in the PowerShell user content folder will determine the location of the user | ||
scoped **PSModulePath**. | ||
- By default, the PowerShell user content folder will be located in the | ||
`$env:LOCALAPPDATA\PowerShell`. | ||
- The new location becomes the location used as the `CurrentUser` scope for PSResourceGet. | ||
- The proposed directory structure: | ||
|
||
``` | ||
C:\Users\UserName\AppData\Local\PowerShell\ | ||
├── powershell.config.json (Not Configurable) | ||
└── <PSContent> (Configurable) | ||
├── Scripts (Not Configurable) | ||
├── Modules (Not Configurable) | ||
├── Help (Not Configurable) | ||
└── <*profile>.ps1 (Not Configurable) | ||
``` | ||
|
||
- The following setting is added to the `powershell.config.json` file: | ||
|
||
**UserPSContentPath** specifies the full path of the content folder. The default value is | ||
`$env:LOCALAPPDATA\PowerShell\PSContent`. The user can change this value to a different path. | ||
|
||
```json | ||
{ | ||
"UserPSContentPath" : "$env:LOCALAPPDATA\\PowerShell\\PSContent", | ||
} | ||
``` | ||
|
||
## User Experience | ||
|
||
- On startup PowerShell will create a directory in AppData and a configuration file. | ||
- The user scoped **PSModulePath** will point to `Modules` folder under the location specified by | ||
**UserPSContentPath**. | ||
- Users can configure a custom location for PowerShell user content by changing the value of | ||
**UserPSContentPath**. | ||
- Users will need to manually move/copy their existing PowerShell user content from the Documents | ||
folder to the new location after enabling the feature. | ||
|
||
## Other considerations | ||
|
||
- The following functionalities will be affected: | ||
- SecretManagement | ||
- SecretManagement extension vaults are registered for the current user context in: | ||
`$env:LOCALAPPDATA\Microsoft\PowerShell\secretmanagement\secretvaultregistry\` | ||
|
||
When an extension vault is registered, SecretManagement stores the full path to the extension | ||
module in the registry. Moving the PowerShell content to a new location will break the vault | ||
registrations. | ||
- Document instructions on how to re-register vaults after moving the content folder. | ||
- Document the need to keep Modules in the Documents folder to so that SecretManagement | ||
continues to work for multiple installs of PowerShell 7 (stable and preview). | ||
|
||
- Use the following script to copy the PowerShell contents folder: | ||
|
||
```pwsh | ||
$newPath = "C:\Custom\PowerShell\Modules" | ||
$currentUserModulePath = [System.Environment]::GetFolderPath('MyDocuments') + "\PowerShell" | ||
Copy-Item -Path $currentUserModulePath -Destination $newPath -Recurse -Force | ||
``` | ||
|
||
- PowerShellGet is hardcoded to install scripts and modules in the user's `Documents` folder. It | ||
will not support this feature. | ||
|
||
## Implementation questions | ||
|
||
- Will the experimental feature be enabled by default? | ||
- Recommendation: No, the user should explicitly enable the feature and copy their existing | ||
PowerShell user content to the new location. | ||
|
||
- How does `$PROFILE` get populated? | ||
- Can profile scripts be moved to `PSContent`? | ||
- The feature needs to update `$PROFILE` to point to profile scripts in the new location. | ||
|
||
- What happens if **UserPSContentPath** is added to the machine-level configuration file in | ||
`$PSHOME/powershell.config.json`? | ||
- Recommendation: Ignore the setting in the machine-level configuration file since this is a user | ||
setting. No error - just ignore it. | ||
Comment on lines
+114
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent errors often lead to confusion. We should warn somewhere (i.e. Event Log, Write-Warning on launch, etc.). As a system administrator I may want to set this on a shared system where we would want to avoid users ever dealing with OneDrive issues. We should just match the existing precedent defined in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Are you talking about this precedence? If so you're suggesting we make this be default AllUsers unless specified? I'm not opposed to this but am worried about breaking the current setups since they would be forced to migrate all their UserPSContent to the new location. Any thoughts @sdwheeler ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While I would tend to agree and caution against breaking existing setups, this would only be the case for admins who deploy this setting retroactively. I would prioritize being consistent in how settings are applied and warn admins what the effect of this on the machine level would have. If we're not consistent then we get into the, "Well in this scenario, the precedent comes from X, and in that scenario it comes from Y." |
||
|
||
- Will **UserPSContentPath** support environment variables (like `$env:USERNAME` or `%USERNAME%`)? | ||
- This could enable a global configuration scenario if we allowed configuration in `$PSHOME`. |
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.
Will the Linux existing CurrentUser modulepaths, etc. be updated to also use this? Will there be a migration approach? I don't like the idea of disparate paths per OS, should follow the XDG standard for both.
https://specifications.freedesktop.org/basedir-spec/latest/
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.
For Linux I'm thinking there is no need to change their existing paths at all. But I do think they would want this customizability.
So a way to achieve this is to add the current modulepaths to powershell.config.json and make the API retrieve the value every time.
For the migration approach, I'm thinking Linux users won't need to do anything if they keep their current path.
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.
The issue is that on Linux, for example Modules, it's LOCALAppData\PowerShell by default (which dotnet does environment translation to XDG) and on windows it'll now be PowerShell\PSContent, so it'll be inconsistent, and if someone does this setting in a portable way, they'll have to account for those differences.
Is the PSContent folder really necessary? Why not just put Modules/Scripts/etc. in
LocalAppData/PowerShell
directly? Then it's the same path on both Windows and Linux (from a dotnet perspective), plus one less level of unnecessary hierarchy. Is there a problem thePSContent
folder solves?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.
To demonstrate:

Should be the same "path" in dotnet on both, but land differently in the OS. That way if I change my preferred path, it'll still work consistently. I feel it should also be lowercase on both but if you want to add the appropriate handling for windows so it is PowerShell, that's fine.