Skip to content
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

Add initial draft #388

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Add initial draft #388

wants to merge 4 commits into from

Conversation

jshigetomi
Copy link

This pull request proposes a new RFC (RFC0066) to change the default location of PowerShell user content on Windows machines from OneDrive to the AppData directory. The goal is to align PowerShell with other developer tools and improve usability by preventing unnecessary syncing issues.

Key changes include:

  • Introduction of RFC0066 to move PowerShell user content to the AppData directory on Windows.
  • Specification of the new directory structure in AppData and the creation of a configuration file to manage the user scoped PSModulePath.
  • Allowing users to customize the location of PowerShell user content, with certain directories being non-configurable.
  • Providing an example script to relocate existing PowerShell content to the new location.

Copy link
Contributor

@sdwheeler sdwheeler left a comment

Choose a reason for hiding this comment

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

There are many more comments and questions I want to add. But start with these changes.

Comment on lines 23 to 25
As a user,
I can customize the location of where PowerShell user content is installed,
so that I can choose to sync with OneDrive.
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
As a user,
I can customize the location of where PowerShell user content is installed,
so that I can choose to sync with OneDrive.
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.

Copy link
Author

Choose a reason for hiding this comment

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

done


## Specification

- This change will only apply to PowerShell on Windows.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why wouldn't we allow macOS and Linux users to relocate these files?

Copy link
Author

Choose a reason for hiding this comment

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

So configurability for all platforms but moving default location only for windows?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds reasonable to me.

Copy link
Author

Choose a reason for hiding this comment

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

done


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

- The proposed directory structure:

C:\Users\UserName\AppData\Local\PowerShell\
├── 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)

C:\Users\UserName\AppData\Local\PowerShell\
├── Modules (Configurable)
├── Scripts (Not Configurable)
├── Profiles (Not Configurable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Profiles are currently in the root of the content folder. I am not against making a profiles subfolder, but is there a reason for this change?

Copy link
Author

Choose a reason for hiding this comment

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

I meant to make it a ps1 and not a directory.

Comment on lines 52 to 54
{
"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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to explain why this is a problem.

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.

Copy link
Author

Choose a reason for hiding this comment

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

done

Comment on lines 60 to 66
- 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
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix formatting

Suggested change
- 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
```
- 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
```

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@sdwheeler sdwheeler left a comment

Choose a reason for hiding this comment

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

More comments

I can customize the location of where PowerShell user content is installed,
so that I can choose to sync with OneDrive.
I can customize the location where PowerShell user content is installed,
so that I can avoid problems created by file sunc solutions like OneDrive.
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
so that I can avoid problems created by file sunc solutions like OneDrive.
so that I can avoid problems created by file sync solutions like OneDrive.

- The proposed directory structure:

C:\Users\UserName\AppData\Local\PowerShell\
├── 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.

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)

Comment on lines +64 to +65
`$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.
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
`$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.
`$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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants