Skip to content

Multiple Configuration Handling #41

@scrthq

Description

@scrthq

Thanks for all your help so far.

I notice the variables under $PSProfile.Variables.Environment aren't clobbered if the PSProfile configuration is imported by leveraging the $PSProfile.ConfigurationPaths. However they are clobbered if I import using Import-PSProfileConfiguration.

It seems the benefit of using Import-PSProfileConfiguration is that the $PSProfile object is immediately updated within the user's current session. Whereas if I just modify the ConfigurationPaths property, not all the properties (if any) in $PSProfile seem to be updated immediately, even after triggering Update-PSProfileConfig and Refresh-PSProfile.

I'm trying to devise a workflow that enables quick install of my PSProfile configuration and easy update too. An ideal workflow for install and update would work like:

  1. Download PSProfile.Configuration.psd1 from my repo/Gist to somewhere like ~
  2. Import-PSProfileConfiguration ~\PSProfile.Configuration.psd1
  3. Use Add-PSProfilePrompt or similar to modify $PSProfile, or modify the configuration file directly, and use Export-PSProfileConfiguration. Update my repo/Gist with newly exported psd1.
  4. Invoke some custom function that I'll likely store as an init script e.g. Update-Profile that will pull my PSProfile.Configuration.psd1 from my repo or Gist and update ~\PSProfile.Configuration.psd1. Said function will use Import-PSProfileConfiguration once downloaded because it immediately updates $PSProfile without needing to reload.

The problem for me is in step 3, I don't want manually strip out user and machine specific properties before uploading to some location. There's more than just what's under $PSProfile.Variables.Environment which is machine and user specific too, e.g.

  • PluginPaths
  • Settings.ConfigurationPath

I have an idea which might help but I'm not sure how to create in PSProfile. What if Export-PSProfileConfiguration offered some parameter to exclude named properties? That could get a little tricky for usage for the user, e.g. how would they specify child properties such as $PSProfile.Settings.ConfigurationPath in the parameter. But it's probably the most flexible idea because if you just offered a switch instead -ExcludeMachineUserSpecificInfo (terrible name I know, but stick with me) then this means you're deciding for the user what properties they can only exclude with little flexibility.

However, maybe I shouldn't be using Import-PSProfileConfiguration after download and maybe I should just ensure $PSProfile.ConfigurationPaths includes ~\PSProfile.Configuration.psd1 and just reload my session if a new version is detected. What's your opinion?

Originally posted by @codaamok in #37 (comment)

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions