Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update-KeePassDatabaseConfiguration Fails with Parameter set resolution error #169

Open
jkdba opened this issue Aug 1, 2019 · 1 comment
Assignees
Labels

Comments

@jkdba
Copy link
Member

jkdba commented Aug 1, 2019

Opened from #167

Error :
"Update-KeePassDatabaseConfiguration: The parameter set can not be resolved using the specified named parameters."

@jkdba jkdba added the bug label Aug 1, 2019
@jkdba jkdba self-assigned this Aug 1, 2019
@fullenw1
Copy link

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 the Key or KeyAndMaster 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants