public/Find-KeePassEntry.ps1

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


function Find-KeePassEntry() {
    <#
        .SYNOPSIS
        Finds an entry based upon a path to the entry using group names
        and entry title.
     
        .DESCRIPTION
        This cmdlet will return null if a group or entry in the path
        is not found, other wise it will transverse the KeePass
        tree to find the entry by path.
     
        .PARAMETER Package
        The object representation of the KeePass database xml file created by
        the `Open-KeePassPackage` function
     
        .PARAMETER Path
        The path to the entry where the title is name of the entry.
     
        .PARAMETER CaseInsenstive
        If present, the search will be case insensitive.
     
     
        .EXAMPLE
        $entries = $Package | Find-KeePassEntry "PackageName/SubGroup/EntryTitle"
     
    #>

        Param(
            [Parameter(Mandatory = $true, Position = 2, ValueFromPipeline = $true)]
            [NerdyMishka.KeePass.IKeePassPackage] $Package,
            
            [Parameter(Mandatory = $true, Position = 0)]
            [string] $Path,
            
            [switch] $CaseInsenstive 
        )
    
     
        return $Package.FindEntry($Path, $CaseInsenstive.ToBool())
    }