qsteenhuis - 2013-09-16

I am trying to write a Powershell script for account creation that will automatically store password entries in KeePass.

When I try to use kpscript to interact with my database, either in my script or interactively on the Powershell command line, I get an error:

PS C:\> &"C:\Program Files (x86)\KeePass Password Safe 2\KPScript.exe" -c:ListEntries "\\path\to\database.kdbx" -pw:"my passphrase"

E: The composite key is invalid!

Make sure the composite key is correct and try again.

I have verified that the password is correct several times. I have also tried changing the codepage to UTF-8 with no change in the results. If I use -keyprompt on the powershell commandline instead of -pw, it works (not something I can do in the final version of the script though).

Just for giggles I tried using read-host -assecurestring to get the variable containing the passphrase, but as expected this doesn't work either.

The same, identical commandline works correctly when invoked from cmd.exe, just not with Powershell.

I am running on Windows 7.

PS C:\> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5472
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

Is this a bug? A known issue with a workaround? Something I need to do differently to get this to work?