PoShKeePass
PoShKeePass copied to clipboard
Is it possible to not overwrite $Global:KeePassConfigurationFile variable at module loading ?
Hello,
KeePassConfiguration.xml is a system-wide configuration file and i want that my users only use a personnal Configuration file. I saw the $Global:KeePassConfigurationFile variable, but when we set it before loading the module, the value is overwrite with default path. Is there a way to prevent this behavior ?
Regards
One thought would be to install the module on the scope of "CurrentUser" which would mean installing for each user on a machine. This would then install the module to their c:\users\name\documents\windowspowershell\modules
path, this is also where the configuration file would be stored, making it only accessible to the logged in user.
Install-Module -Name PoShKeePass -Scope CurrentUser
I'll give a try :)
As both a sysadmin who manages the configuration of workstations in my company and a devops guy who uses KeePass, I'd like to have the module installed systemwide (so better protected and updateable administratively), but to have the configuration file stored per-user (under $Env:LocalAppData, probably) - like all applications should behave by default.
A rough sketch of the solution could look like that:
- move the initialization code (which touches the configuration file) from the .psm1 to a function
- make that function support passing a custom config file path - the function would store this path in a module-scoped variable
- the function could also accept some convenience switches, enabling easy selection of default per-user and per-machine config paths
- export that function from the module, so that the user can explicitly invoke it and pass a custom config path
- in each public function, if the configuration file has not been initialized yet, call the initialization function with a default path
- I'd prefer the default path to be per-user (under $Env:LocalAppData), but I understand you may be reluctant to make such a breaking change (although it would increase the security of the module)
If such design would be OK, I could work on a draft.