-
Notifications
You must be signed in to change notification settings - Fork 58
Getting Started
Getting started with PSKeePass is fairly simple and requires a small initial setup.
- If you would like to install this module from the PSGallery, run the following command.
Install-Module -Name PoShKeePass
- 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.
-
-DatabaseProfileName
Specify the name of the new profile. -
-DatabasePath
Specify the location of the KeePass database file (.kdbx). -
-KeyPath
Specify the location of the KeePass Key Authentication file if you use one. -
-UseMasterKey
Specify this switch (boolean) flag if your KeePass database uses a password for authentication. -
-UseNetworkAccount
Specify this switch (boolean) flag if your KeePass database uses your Windows Account for authentication.
- 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
Now that you have a KeePass database configuration profile getting KeePass entries is pretty easy.
- 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:
-
They are delimited by a forward slash
/
. -
The Root-Group/Database Name must be included in the path.
-
There is no trailing forward slash at the end of the path.
-
Paths are not case sensitive.
Get-KeePassEntry -KeePassEntryGroupPath 'pskeepasstestdatabase/General' -AsPlainText -DatabaseProfileName TestDB
Title UserName Password FullPath
----- -------- -------- --------
TestTitle TestUser v2KVQT5cpX8jNsfN9iKk PSKeePassTestDatabase/General
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