-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathFromPowershell.ps1
More file actions
55 lines (44 loc) · 1.42 KB
/
FromPowershell.ps1
File metadata and controls
55 lines (44 loc) · 1.42 KB
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
function ExitWithCode
{
param
(
$exitcode
)
$host.SetShouldExit($exitcode)
exit $exitcode
}
function Example
{
$options = [pscustomobject]@{
FieldNames = @('extra field 1', 'extra password 1')
AttachmentNames = @('example_attachment.txt')
}
$object = KeePassEntry -title "Sample Entry" -options $options
if ($object -eq $null) {
Write-Host "Communication failed:"
Write-Host "- Is KeePass not started, locked or is the database not opened ?"
Write-Host "- Has KeePassCommander.dll been copied to the directory containing KeePass.exe ?"
Write-Host "- Is the entry not allowed to be queried (e.g. not permitted when using the filesystem) ?"
return 2
}
$object | Out-String | Write-Host
return 0
}
# find KeePassEntry.ps1
$KeePassEntry_ps1 = Join-Path -Path $PSScriptRoot -ChildPath "KeePassEntry.ps1"
if (-Not (Test-Path $KeePassEntry_ps1)) {
$KeePassEntry_ps1 = Join-Path -Path $PSScriptRoot -ChildPath "..\bin\release\KeePassEntry.ps1"
if (-Not (Test-Path $KeePassEntry_ps1)) {
Write-Host "KeePassEntry.ps1 not found"
ExitWithCode -exitcode 1
}
}
# include KeePassEntry.ps1 containing function KeePassEntry
. $KeePassEntry_ps1
# BEGIN example
$exitcode = Example
# END example
# remove included function KeePassEntry
Remove-Item function:\KeePassEntry
#exit
ExitWithCode -exitcode $exitcode