psKeePass.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$Script:mInfo = $MyInvocation.MyCommand.ScriptBlock.Module
$Script:mInfo.Description = "Author: Leonardo Rizzi"

# Store generic config retrieve from parameters.json
#$Script:config = (Get-Content -LiteralPath $(Join-Path $PSScriptRoot enviroment\parameters.json) -ErrorAction Stop) -join "`n" | ConvertFrom-Json

Import-Module (Join-Path $PSScriptRoot common\common.psm1) -Prefix KP 

#Load all .NET binaries in the folder
$pathToKeePassFolder = Join-Path $PSScriptRoot bin

###########################################################################
#
# Load the classes from KeePass.exe:
#
###########################################################################
$KeePassEXE = (Join-Path $pathToKeePassFolder KeePass.exe)
if (Test-Path $KeePassEXE)
{
    try
    {
        [Reflection.Assembly]::LoadFile($KeePassEXE)
    }
    catch [Exception]
    {
        Write-Host $_ -ForegroundColor Red
        break
    }
}
else
{
    Write-Host "Assembly $($KeePassEXE) is not found."
    break
}



Enum EntryKeys
{
    UserName
    Title
    URL
    Notes
    Password
}



#region Include
    . (Join-Path $PSScriptRoot TabExpansion.ps1)
    . (Join-Path $PSScriptRoot Get-KPEntry.ps1)
    . (Join-Path $PSScriptRoot New-KPEntry.ps1)
    . (Join-Path $PSScriptRoot Set-KPEntry.ps1)
    . (Join-Path $PSScriptRoot Remove-KPEntry.ps1)
#endregion Include



# Common Module
Export-ModuleMember -Function New-KPSecurePassword
Export-ModuleMember -Function Get-KPSecurePassword
Export-ModuleMember -Function Remove-KPSecurePassword
# KeePass Module
Export-ModuleMember -Function Get-KPEntry
Export-ModuleMember -Function New-KPEntry
Export-ModuleMember -Function Set-KPEntry
Export-ModuleMember -Function Remove-KPEntry