Closed codaamok closed 4 years ago
Checking this out, thanks @codaamok ♥️
Alright, here's a more complete response @codaamok :
$env:ComputerName
and $env:UserName
vars from being set other than what they should be set to on the current machineConfiguration
but I was planning on adding a spot to load in a separate config from a defined/custom path to layer against it. This would let you first import whatever is at $PSProfile.Settings.ConfigurationPath
, then import the custom path on top of it (whatever is layered on last should take precedence in the event there are conflicts) --- would that satisfy the ask around the side question?Yes, that sounds like a really good solution!
Heyo @codaamok - Just pushed out v0.6.3 that should get you covered here. Let me know if you have any questions!
Hello :-) this looks very good, thank you very much.
I have noticed that when I call Add-PSProfileConfigurationPath -Path "C:\somescript.ps1" -Save
, then the contents of my current $PSProfile.Settings.ConfigurationPath
jump around and the indentation continuously grows for the prompt strings every time I invoke the Add-PSProfileConfigurationPath
function. Not a big deal I don't think, but thought you should know as it's probably unintended.
Sorry to spam! I would also expect the same command (Add-PSProfileConfigurationPath -Path "C:\somescript.ps1" -Save
) to update the contents of the configuration file but it doesn't. Unless I'm missing something?
@codaamok ::
I have noticed that when I call
Add-PSProfileConfigurationPath -Path "C:\somescript.ps1" -Save
, then the contents of my current$PSProfile.Settings.ConfigurationPath
jump around and the indentation continuously grows for the prompt strings every time I invoke theAdd-PSProfileConfigurationPath
function. Not a big deal I don't think, but thought you should know as it's probably unintended.
I've seen the same and I think it's how Configuration
is saving the contents when saved often? I mostly notice it with ScriptBlock's. The end result will always be the same, but if you're looking at the config file, it will be a mess of extraneous indentation. Still trying to nail that one down.
Sorry to spam! I would also expect the same command (Add-PSProfileConfigurationPath -Path "C:\somescript.ps1" -Save) to update the contents of the configuration file but it doesn't. Unless I'm missing something?
It expects a PSD1 file, not a PS1, and will semi-silently skip it if it isn't a PSD1. Ref: https://github.com/SCRT-HQ/PSProfile/blob/main/PSProfile/Public/Configuration/Add-PSProfileConfigurationPath.ps1#L37
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:
PSProfile.Configuration.psd1
from my repo/Gist to somewhere like ~
Import-PSProfileConfiguration ~\PSProfile.Configuration.psd1
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.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?
I'd like to use
Export-PSProfileConfiguration
to export the PSProfile config and use it across multiple machines, however within the psd1 there's multiple properties that would overwrite some environment variables when usingImport-PSProfileConfiguration
.Is it possible to make the exported data not include machine or user specific information?
Also, as a side question, is it possible to configure
$PSProfile.Settings.ConfigurationPath
permanently on a system? Otherwise, I'd imagine the only way to achieve a consistent change to this property is via changing it inprofile.ps1
and that invoking a reload of PSProfile.