PoshCode / Configuration

A module to help other modules have settings
MIT License
176 stars 27 forks source link

Please add an example for export-configuration -DefaultPath <path> #25

Closed AspenForester closed 3 years ago

AspenForester commented 5 years ago

As I read the parameter description in the help for Export-Configuration, the DefaultPath parameter is used to copy a configuration file that's distributed with the module to one of the three scope-based locations. As such, I'm not sure I'd expect a hashtable to be passed as input. But clearly, -InputObject remains a required parameter value.

Having an example of your intended use would be helpful.

If I understood how it was to be used, I'd submit PR to update the help.

Thanks!

Jaykul commented 5 years ago

Actually, I don't that parameter is used in Export-Configuration (anymore?). I could probably remove it except that it might break users who've called it passing a value, not realizing it's ignored.

The idea is that you always call Import-Configuration first, and it looks in all the locations. It actually loads the DefaultPath first, and then overwrites it with any values it finds in the other locations.

If you change the configuration object and pass it back to Export-Configuration then the modified object is stored in your preferred path (by default, inside AppData) -- so in the future when you Import-Configuration those settings will overwrite the defaults.

When you make a new version of your module, you can add properties to the default file, and because of the layering. those values will show up in the configuration objects (until you re-export them and update the user's copy).