Skip to content

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions Draft-Accepted/RFC0066-PowerShell-User-Content-Location
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
RFC: RFC0066
Author: Justin Chung
Status: Draft
SupercededBy: N/A
Version: 1.0
Area: Core
Comments Due: 05/03/2025
Plan to implement: Yes
---

# PowerShell User Content Location

This RFC proposes moving the current PowerShell user content location out of OneDrive to the AppData directory on Windows machines.

## Motivation

- 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 causes unnecessary syncing of configuration 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.

As a user,
I can customize the location of where PowerShell user content is installed,
so that I can choose to sync with OneDrive.

## User Experience

- On startup PowerShell will create a directory in AppData and a configuration file.
- In the configuration file the user scoped PSModulePath will point to AppData/PowerShell/Modules.
- Users can opt out of this new location by specifying a desired user scoped module path in the configuration file.

## Specification

- This change will only apply to PowerShell on Windows.
- This will be an experimental feature.
- The PowerShell user content folder will be located in the AppData.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- The PowerShell user content folder will be located in the AppData.
- The PowerShell user content folder will be located in the `"$env:LOCALAPPDATA\PowerShell"`.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or should this be "$env:LOCALAPPDATA\Microsoft\PowerShell"? The already use this location module cache and SecretManagement.

Copy link
Author

Choose a reason for hiding this comment

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

$env:LOCALAPPDATA\Microsoft\PowerShell makes more sense

Copy link
Contributor

Choose a reason for hiding this comment

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

We should get @SteveL-MSFT feedback. I prefer to not create yet another PowerShell folder somewhere, but that folder get very full of files.

- A configuration file in the PowerShell user content folder will determine the location of the user scoped PSModulePath.
- The user will be responsible for specifying thier desired install location using PSResourceGet.
- The location of Modules is configurable
- The location of this folder is not configurable.
- The proposed directory structure:

C:\Users\UserName\AppData\Local\PowerShell\
Copy link
Author

Choose a reason for hiding this comment

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

@sdwheeler Is this directory structure and configurability setup what you mean?

├── Modules (Configurable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't we allowing the location of the content folder to be changed? I want all my user files in one location, I don't want modules in one place and scripts/profiles in another.

Copy link
Author

Choose a reason for hiding this comment

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

I see. So only the location of the config file itself is not configurable and all other files is configurable through the config file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. So only the location of the config file itself is not configurable

Correct. Whether the other locations are configurable is open to discussion. My vision was that we would only allow configuration of the PSContentPath. Everything else would be in that location.

PSContentPath (configurable)
├── Scripts (Not Configurable)
├── Modules (Not Configurable)
├── Help (Not Configurable)
├── profile.ps1 (Not Configurable)

├── Scripts (Not Configurable)
├── Profiles (Not Configurable)
└── PSModulePathConfig.json (Not Configurable)

- The proposed json file:

{
"PSModulePath" : "C:\\Users\\chungjustin\\PowerShell"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

PSModulePath is already a value used in the config file. I suggest changing the name for this configuration to UserPSModulePath. If we allow rehoming of the content folder then use UserPSContentPath.

Use the suggested formatting.

Suggested change
{
"PSModulePath" : "C:\\Users\\chungjustin\\PowerShell"
}
```json
{
"PSModulePath" : "C:\\Users\\chungjustin\\PowerShell"
}
```

Question: Should setting PSModulePath and the user paths be mutually exclusive?

Copy link
Author

Choose a reason for hiding this comment

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

I think making them not mutually exclusive is a good idea. And maybe even separating the scripts and profile out too?

{
"PSModulePath": "C:\Users\user\PowerShell",
"UserPSModulePath": "C:\Users\user\PowerShell",
"UserPSContentPath": "C:\Users\user\PowerShellContent"
"UserScriptPath": "C:\Users\user\PowerShellContent"
"UserProfilePath": "C:\Users\user\PowerShellContent"
}


## Alternate Proposals and Considerations

- The following functionalities will be affected:
- Secret Management.
- Use the following script to relocate the PowerShell contents folder:

```pwsh
$newPath = "C:\Custom\PowerShell\Modules"
$currentUserModulePath = [System.Environment]::GetFolderPath('MyDocuments') + "\PowerShell\Modules"
Move-Item -Path $currentUserModulePath -Destination $newPath -Force
```