Getting Started - PSKeePass/PoShKeePass GitHub Wiki

Getting started with PSKeePass is fairly simple and requires a small initial setup.

Install

  • If you would like to install this module from the PSGallery, run the following command.
Install-Module -Name PoShKeePass

Setup

  • Once you have the PSKeePass module then you will need to import it.
Import-Module 'C:\your\path\PSKeePass' -Force

I like to use the -Force flag all the time just so when I make an edit to the module I know I will always get the updated code.

  • Next you will need to create a PSKeePass Database Configuration Profile.

This is used to store the location of your database file and what type of authentication you use so the authentication process can be automated as much as possible when you go to interact with your database.

You can view the actual config file (KeePassConfiguration.xml) in the PSKeePass Module Directory once it is created.

To create this profile use the New-KeePassDatabaseConfiguration function, which supports the following options.

  1. -DatabaseProfileName Specify the name of the new profile.

  2. -DatabasePath Specify the location of the KeePass database file (.kdbx).

  3. -KeyPath Specify the location of the KeePass Key Authentication file if you use one.

  4. -UseMasterKey Specify this switch (boolean) flag if your KeePass database uses a password for authentication.

  5. -UseNetworkAccount Specify this switch (boolean) flag if your KeePass database uses your Windows Account for authentication.

Examples

  • Create a database profile with the authentication type that uses a KeyFile:
New-KeePassDatabaseConfiguration -DatabaseProfileName 'KeyFileDB' -DatabasePath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyFile.kdbx" -KeyPath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyFile.key"
  • Create a database profile with the authentication type that uses a KeyFile and MasterKey (aka Password):
New-KeePassDatabaseConfiguration -DatabaseProfileName 'KeyAndMasterKeyDB' -DatabasePath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyAndMaster.kdbx" -KeyPath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyAndMaster.key"
  • Create a database profile with the authentication type that uses a KeyFile and a Windows Account:
New-KeePassDatabaseConfiguration -DatabaseProfileName 'KeyFileAndWindowsAccountDB' -DatabasePath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyFile.kdbx" -KeyPath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\KeyFile.key" -UseNetworkAccount
  • Create a database profile with the authentication type that uses a Windows Account:
New-KeePassDatabaseConfiguration -DatabaseProfileName 'WinDB' -DatabasePath "C:\dev\git\PSKeePass\Test\Includes\AuthenticationDatabases\WindowsDB.kdbx" -UseNetworkAccount

Getting KeePass Entries

Now that you have a KeePass database configuration profile getting KeePass entries is pretty easy.

Examples

  • Get all KeePass entires as a plain text powershell object.
Get-KeePassEntry -AsPlainText -DatabaseProfileName TestDB

Title           UserName   Password FullPath
-----           --------   -------- --------
Sample Entry    User Name  Password PSKeePassTestDatabase
Sample Entry #2 Michael321 12345    PSKeePassTestDatabase
  • Get all KeePass entries of a specific group. In order to do this you must specify the group path in which the entries you are looking for are stored.

For example if I want to get all of the entries of the group General I would specify a path like this: PSKeePasTestDatabase/General.

So a couple of things to note here about Group Paths:

  1. They are delimited by a forward slash /.

  2. The Root-Group/Database Name must be included in the path.

  3. There is no trailing forward slash at the end of the path.

  4. Paths are not case sensitive.

Get-KeePassEntry -KeePassEntryGroupPath 'pskeepasstestdatabase/General' -AsPlainText -DatabaseProfileName TestDB

Title     UserName Password             FullPath
-----     -------- --------             --------
TestTitle TestUser v2KVQT5cpX8jNsfN9iKk PSKeePassTestDatabase/General

Other Supported Functions

Feel free to view the help text on these functions for more examples and notes.

(Get-Module PSKeePass | Select-Object -exp ExportedCommands).Keys
ConvertTo-KPPSObject
Get-KeePassDatabaseConfiguration
Get-KeePassEntry
Get-KeePassGroup
New-KeePassDatabaseConfiguration
New-KeePassEntry
New-KeePassGroup
New-KeePassPassword
Remove-KeePassDatabaseConfiguration
Remove-KeePassEntry
Remove-KeePassGroup
Update-KeePassEntry
Update-KeePassGroup