Update-KeePassDatabaseConfiguration Fails with Parameter set resolution error
jkdba opened this issue · 1 comments
Opened from #167
Error :
"Update-KeePassDatabaseConfiguration: The parameter set can not be resolved using the specified named parameters."
I had a look at the code.
The error means "PowerShell cannot determine which parameter set it should use".
For example:
- If the command line contains only the
-DatabasePath
parameter, this can be any parameter set. PowerShell does not know which one to use... - If the command line contains only the
-KeyPath
parameter, this can be either theKey
orKeyAndMaster
parameter set. PowerShell does not know which one to use...
Furthermore, the -DatabasePath
parameter is a member of all parameter sets, which makes the thing more difficult to manage and is part of the cause of the problem. It's better to remove all parameter sets from a parameter which is a member of all parameter sets.
By the way, why implementing parameter sets here? A user should be able to update any of those options... I guess just a copy/paste from the New-KeePassDatabaseConfiguration.ps1
script :)
The problem is the same as with the New-KeePassDatabaseConfiguration.ps1
script. Fortunately, when we create a new database configuration we usually use a maximum of parameters. Thus the problem does not necessarily appear for all users with this cmdlet...
Last point: why shouldn't we be able to use a master password, with a file and also a network account? With the desktop application, we can combine it all. However, with the current implementation of parameter sets, this is not possible.
If I accurately understand what you want to achieve, my suggestion is to remove all parameter sets and make a check in the Begin
section:
if(
-not(
$PSBoundParameters.Keys.GetEnumerator().Where({
$PSItem -match '^KeyPath$|^UseNetworkAccount$|^UseMasterKey$'
})
)
){
Throw 'You must choose at least one authentication method!'
}
Anyway, thanks a lot for having taken your time to create this module. I use it a lot :)